On Apr 11, 6:58 am, "aiooua" <aio...@gmail.c omwrote:
On Apr 10, 8:34 pm, "James Kanze" <james.ka...@gm ail.comwrote:
On Apr 9, 2:34 pm, "aiooua" <aio...@gmail.c omwrote:
however, i have a related, but different problem. i tried the code as
printed in the book[#1] and couldn't get it to work.
---
/* begin code */
template<boolst ruct CompileTimeChec ker{ CompileTimeChec ker(...); };
template<struct CompileTimeChec ker<false{ };
#define STATIC_CHECK(ex pr, msg) { class ERROR_##msg {};
(void)sizeof(Co mpileTimeChecke r<(expr) != 0>((ERROR_##msg ()))); }
Are you sure you didn't forget a \ at the end of the previous
line? This line would make sense as part of the macro.
the macro was well-formed when i compiled, it got wrapped into two
lines (maybe because of line-length limits or something) while i
posted it here.
You mean that the line following the #define was actually on the
same line?
The reason I asked is because when I added the \ to the end of
the line with the #define, the code worked as expected (i.e.
failed to compile). (Of course, without the \, it failed to
compile as well.)
I'm not sure about the exact error message you got---it seems a
unlike what the book says, and what i expected i did not get any
error.
however, i got the following warning.
--
test.cpp:4: warning: ISO C++ forbids applying `sizeof' to a function
type
--
If I add the \ to the end of the line, I get:
cerr.cc: In function 'int main()':
cerr.cc:5: error: invalid application of 'sizeof' to a function
type
from g++. Both with no options, and with my usual options.
Maybe you have set some option somewhere to make g++ treat this
as a warning only.
--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34