On Thursday 17 April 2003 02:13 am, Fabian Cenedese wrote:
remove run-time checks of compile-time constants.
I dearly wish that there were a way of doing compile-time
assertion, but
there isn't, so it has to be done by a runtime assertion.
Well, there seem to be some reasonable tricks for that: http://www.jaggersoft.com/pubs/CVu11_3.html http://www.panelsoft.com/murphyslaw/apr01.htm
This is for C++ but maybe also adaptable for C: http://www.boost.org/libs/static_assert/static_assert.htm
bye Fabi
ah, the hidden powers of the preprocessor -- how it drives us to obsfucation with it's robotic stupidity... I wonder, is cpp a turing machine?
I don't think so.
Makes me want to implement vim as a sed script ;)
:-)
nonetheless, considering one must sometimes make do with what one has, that array-of-zero trick is super-clever... perhaps I'll actually make a constructive patch out of this debacle yet..
Note that Wine already have a macro for this that is not a Wine specific invention but is rather a feature of the Win32 API.
From include/winnt.h:
/* Compile time assertion */
#if defined(_MSC_VER) # define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1] #elif defined(__GNUC__) # define C_ASSERT(e) extern char __C_ASSERT__[(e)?1:-1] #endif