Implement generic swap macro in C [duplicate]

This works well only with integers. For floats it will fail (e.g. try running it with a very large float and a very small one). I would suggest something as follows: #define swap(x,y) do \ { unsigned char swap_temp[sizeof(x) == sizeof(y) ? (signed)sizeof(x) : -1]; \ memcpy(swap_temp,&y,sizeof(x)); \ memcpy(&y,&x, sizeof(x)); \ memcpy(&x,swap_temp,sizeof(x)); \ } while(0) … Read more

Are there any drawbacks to using anonymous functions in JavaScript? E.g. memory use?

All JavaScript functions will behave in the same manner in that they inherit the variable environments in entire scope chain leading up to, and including, themselves. This is equally true for both anonymous and named functions. This chain of references to the outer environments stays with each function, even if the function is passed into … Read more

JavaScript ES6: Test for arrow function, built-in function, regular function?

Believe it or not… Testing for presence of “=>” in string representation of a function is likely the most reliable way (but not 100%). Obviously we can’t test against either of 2 conditions you mentioned — lack of prototype property and lack of [[Construct]] as that might give false positives with either host objects or … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)