diff options
author | Laszlo Ashin <kodest@gmail.com> | 2008-11-22 14:22:32 +0100 |
---|---|---|
committer | Laszlo Ashin <kodest@gmail.com> | 2008-11-22 14:28:11 +0100 |
commit | 457a6f4beef0550c21ecaa7615ac6ec3d9772258 (patch) | |
tree | a6a09c68c277e42e5336c05d27ac0b6369d7c6dd /src | |
parent | 0bad84066bc12a370b8f1e54c37f705fad21929b (diff) | |
download | mpd-457a6f4beef0550c21ecaa7615ac6ec3d9772258.tar.gz mpd-457a6f4beef0550c21ecaa7615ac6ec3d9772258.tar.xz mpd-457a6f4beef0550c21ecaa7615ac6ec3d9772258.zip |
utils: introduce assert_static()
assert_static() will help us to find false asserts in compile time. Of
course it only works in case of expressions which can be evaluated
compile time. It cannot be used in global scope.
Diffstat (limited to 'src')
-rw-r--r-- | src/utils.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h index 64fac0ded..6e2d288fc 100644 --- a/src/utils.h +++ b/src/utils.h @@ -29,6 +29,15 @@ #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) +#ifndef assert_static +/* Compile time assertion developed by Ralf Holly */ +/* http://pera-software.com/articles/compile-time-assertions.pdf */ +#define assert_static(e) \ + do { \ + enum { assert_static__ = 1/(e) }; \ + } while (0) +#endif /* !assert_static */ + char *myFgets(char *buffer, int bufferSize, FILE * fp); void stripReturnChar(char *string); |