c++ - Why can't I define these macro names? -



c++ - Why can't I define these macro names? -

if create define @ command -dfirst , -dsecond bunch of errors:

in file included main.cpp:1: in file included /usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/iostream:39: in file included /usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/ostream:38: in file included /usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/ios:40: in file included /usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/bits/char_traits.h:39: in file included /usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/bits/stl_algobase.h:64: /usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/bits/stl_pair.h:101:11: error: expected fellow member name or ';' after declaration specifiers _t1 first; /// @c first re-create of first object ~~~ ^ <command line>:1:15: note: expanded here #define first 1 ^ ... ^ fatal error: many errors emitted, stopping [-ferror-limit=] 20 errors generated.

but if utilize capital first , second it's fine.

if define first , sec before including anything, includes std::pair within <algorithm>, screw code, because variables within std::pair called first , second, , macro defined that, expands names look defined to, making code malformed.

basically, same doing

#define 1 class a{ };

this not compile, because gets converted 1, , 1 not valid class name

c++

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -