Problem with 'static asserts' in gcc-3.3.1 --- error messages have less detail.

Warren_Baird@cimmetry.com Warren_Baird@cimmetry.com
Wed Aug 27 16:09:00 GMT 2003




Hi all,

Recently I borrowed a trick from the Boost toolkit's static_assert.hpp to force
developers to not use certain functions -  I defined bodyless structs who's name
contains the message I want to give, and then take the sizeof that struct.
Something like:

struct ERROR___Please_use_bar_instead_of_foo;
#define foo(x) sizeof(ERROR___Please_use_bar_instead_of_foo)

With MSCV 6 and 7, and gcc 3.2 and earlier, you get a message like:
testErrors.cpp:14: `sizeof' applied to incomplete type `
   ERROR___Please_use_bar_instead_of_foo'

which is perhaps not perfect, but it gets the message across.   Unfortunately
with gcc-3.3.1 the C compiler does the right thing, but the C++ compiler just
says:

testErrors.cpp:14: error: invalid application of `sizeof' to an incomplete type

Which isn't particularly useful...

Does anyone have any idea why this was changed, or if there is any way to
restore the old error messages?  I was half-way tempted to report this as a
bug...

Failing that - does any one have any other suggestions of ways to do this?

Thanks,

Warren.




More information about the Gcc-help mailing list