Would it be better to define the below functions as macro or inline functions? Or is it better to use normal functions and trust the compiler, to maintain (in my opinion) better readability?
typedef unsigned char byte; void set_size_mark(byte size_mark, byte *ptr) { *ptr += size_mark << 1; } byte get_size_mark(byte *ptr) { return *ptr >> 1; }
#define ARRAYLEN(x) (sizeof(x)/sizeof(*x))would be difficult to do as a function.... or when you need something to happen at compile time, such as a compile time assertinline. They tend to do that if the function is called many times in the same place (which is also when it is the more important to inline!) That's what force inline is for. The exact syntax various with compilers.