[ros-dev] [ros-diffs] [cwittich] 32018: compilerflags can be set for compiler {ALL|CC|CPP} now (ALL is default)

Timo Kreuzer timo.kreuzer at web.de
Sun Jan 27 15:06:20 CET 2008


arrays of size 0 are no problem for gcc both in C and C++, so you should 
use something like

#define ct_assert(x) typedef char _ct_assert__[(x)? 1 : -1];

tamlin at algonet.se schrieb:
> Actually, I'd say the stupidity is in using a runtime assert, when a
> compile-time assert will do the trick (not using CPU at runtime, while 
> enforcing the condition).
>
> Unless memory fails me, in C++ you can implement ct_assert(x) like:
>
> typedef char[x!=0] foo;
>
> as an array of size zero is an error.
>
> How does current C compilers react to typedefs of zero-sized arrays? 
> Sure, one can't use it exactly as in C++, but it could still be useful 
> to at least know about this idiom.
>
> Problems should be trapped as early as possible.
>
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.reactos.org/pipermail/ros-dev/attachments/20080127/81f95453/attachment.html 


More information about the Ros-dev mailing list