Is there a built in swap function in C?

No. C++ builtin swap function: swap(first,second); Check this: http://www.cplusplus.com/reference/algorithm/swap/ You can use this to swap two variable value without using third variable: a=a^b; b=a^b; a=b^a; You can also check this: https://stackoverflow.com/questions/756750/swap-the-values-of-two-variables-without-using-third-variable How to swap without a third variable?

Missing separator in Makefile?

Given your update with the error, check what you have on the line before those ${CC} commands. Many make programs require a real tab character before the commands and editors that put in eight spaces (for example) will break them. That’s more often than not the cause of the “Missing separator” errors. You can see …

Read more

what “inline __attribute__((always_inline))” means in the function?

The often referenced gcc documentation for always_inline is incomplete. always_inline attribute makes gcc compiler: Ignore -fno-inline (this is what the documentation says). Ignore the inlining limits hence inlining the function regardless. It also inlines functions with alloca calls, which inline keyword never does. Not produce an external definition of a function with external linkage if …

Read more

How to find the position of the only-set-bit in a 64-bit value using bit manipulation efficiently?

Multiply the value by a carefully designed 64-bit constant, then mask off the upper 4 bits. For any CPU with fast 64-bit multiplication, this is probably as optimal as you can get. int field_set(uint64_t input) { uint64_t field = input * 0x20406080a0c0e1ULL; return (field >> 60) & 15; } // field_set(0x0000000000000000ULL) = 0 // field_set(0x0000000000000080ULL) …

Read more