gcc problem
I've been working on some C++ code and testing in both MSVC 2005 Pro, and gcc 4.1.2. Some of my functions have names like and(), not(), xor(), etc. These have no problems in MSVC, but in gcc, it seems to be translating it to the C/C++ operator equivelents and reeking havoc on compiling. I haven't had a lot of luck searching thought the gcc docs (something about searching for the words AND and NOT not working too well :) ). Is there a gcc command line argument that can supress this conversion?
You really shouldn't use those, but if you insist:
(Note that gcc is for C only, while g++ is for C++, but they both accept this argument.)
gcc -fno-operator-names
(Note that gcc is for C only, while g++ is for C++, but they both accept this argument.)
I'm kind of curious why you say I shouldn't use those names (besides the gcc compatibility issues). As far as the actualy C++ language, to my knowledge, they aren't reserved words and they are very much discriptive of the job they are performing.
They are members of a big integer class and they are performing the operations they desribe.
I can always rename them if I need too.
They are members of a big integer class and they are performing the operations they desribe.
I can always rename them if I need too.
Take a look at the iso646.h header. Not all keyboards have the characters needed for and/or/etc. This header provides alternates that work on most keyboards.
Your symbol names happen to conflict with the ones in iso646. gcc probably includes them by default. Erissian has a good suggestion, but you might want to consider renaming your symbols to avoid the conflict. Alternatively, you could use iso646.h/not override gcc if that meets your needs.
Your symbol names happen to conflict with the ones in iso646. gcc probably includes them by default. Erissian has a good suggestion, but you might want to consider renaming your symbols to avoid the conflict. Alternatively, you could use iso646.h/not override gcc if that meets your needs.
I haven't check the file, but I that is a good explination. If it is the header though, then I would have to assume they are using macros, because this is a method inside a class and beneth two namespaces.
Just to avoid the problem, I have gone ahead and renamed them.
Just to avoid the problem, I have gone ahead and renamed them.
Quote:Original post by Rattrap
I haven't had a lot of luck searching thought the gcc docs...
The alternate operator keywords are a part of the standard, but can be turned off for compatibility. Visual Studio's default seems to be to not conform and turn them off, GCC's seems to be to conform by default and enable them. I would suggest you just turn them off in GCC (see above post).
Maybe I missed something but why don't you use operator overloading instead of making functions with the operator names?
I'm going to have overloaded operators when it's done. They are just going to wrap the current functions.
To emphasize, these alternative tokens are full-fledged reserved words in ISO C++, not macros or other library feature. The <iso646.h> header is a C99 one, and there's no corresponding <ciso646> C++ header. 2.5 [lex.digraph] has the relevant wording.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement