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

tamlin at algonet.se tamlin at algonet.se
Sun Jan 27 05:27:44 CET 2008


Alex wrote:

>On 26-Jan-08, at 2:34 PM, Marc Piulachs wrote:
>
>> Hi,
>>
>> I'm not very sure about r32018-r32022.
>>
>> Some compiler warnings are stupid and useless, some others not.
>
>This one is stupid.

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.

-- 
Mike


More information about the Ros-dev mailing list