Skip to content

Instantly share code, notes, and snippets.

@silentbicycle
Created March 30, 2012 14:26
Show Gist options
  • Save silentbicycle/2251890 to your computer and use it in GitHub Desktop.
Save silentbicycle/2251890 to your computer and use it in GitHub Desktop.
fixed-width macro lines
/* macro.h */
#define GREATEST_ASSERT_EQm(MSG, EXP, GOT) \
do { \
greatest_info.msg = MSG; \
greatest_info.fail_file = __FILE__; \
greatest_info.fail_line = __LINE__; \
if ((EXP) != (GOT)) { \
GREATEST_CALL_TEARDOWN(); \
return -1; \
} \
greatest_info.msg = NULL; \
} while (0)
/* use.c */
#include "macro.h"
TEST test_example() {
GREATEST_ASSERT_EQm("example message", x + 1, 10);
GREATEST_ASSERT_EQm("example message", x*x, y*y);
}
/* To expand the macro and wrap lines at 70 characters:
$ cpp use.c | fmt -w 70
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment