diff options
Diffstat (limited to 'spec/compiler.h')
| -rw-r--r-- | spec/compiler.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/compiler.h b/spec/compiler.h new file mode 100644 index 0000000..b626f1a --- /dev/null +++ b/spec/compiler.h @@ -0,0 +1,23 @@ +/** @file spec/compiler.h + * @brief Useful macros. Inspired by Linux compiler*.h and kernel.h. + * @author bblum S2011 + */ + +#ifndef _SPEC_COMPILER_H +#define _SPEC_COMPILER_H + +/* Function annotations */ +#ifndef NORETURN +#define NORETURN __attribute__((__noreturn__)) +#endif + +#define MUST_CHECK __attribute__((__warn_unused_result__)) + +/* Force a compilation error if condition is false */ +#define STATIC_ZERO_ASSERT(condition) switch(0){case 0:case (condition):;} +#define STATIC_NULL_ASSERT(condition) STATIC_ZERO_ASSERT(condition) + +/* Force a compilation error if condition is false */ +#define STATIC_ASSERT(condition) STATIC_ZERO_ASSERT(condition) + +#endif /* !_SPEC_COMPILER_H */ |
