c-generic-ring-buffer
c-generic-ring-buffer copied to clipboard
A Bug In Macro
You should surround your macro by do{...}while(0)
What benefit does this provide?
It will work in cases where you do:
if (whatever == 1)
MACRO
Which would fail with multiple statements inside the macro (only the first would be guarded by the if-statement). The do-while wrapper makes the macro safe in any context.
If someone would like to contribute this with tests, I'll happily pull it in. :-)