gcc problem

Started by
8 comments, last by Sharlin 16 years, 10 months ago
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?

"I can't believe I'm defending logic to a turing machine." - Kent Woolworth [Other Space]

Advertisement
You really shouldn't use those, but if you insist:
gcc -fno-operator-names


(Note that gcc is for C only, while g++ is for C++, but they both accept this argument.)
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
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.

"I can't believe I'm defending logic to a turing machine." - Kent Woolworth [Other Space]

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.
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.

"I can't believe I'm defending logic to a turing machine." - Kent Woolworth [Other Space]

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).

Stephen M. Webb
Professional Free Software Developer

Here's this too:

http://cs.smu.ca/~porter/csc/ref/cpp_keywords.html
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
Maybe I missed something but why don't you use operator overloading instead of making functions with the operator names?
"Pfft, Facts! Facts can be used to prove anything!" -- Homer J. Simpson
I'm going to have overloaded operators when it's done. They are just going to wrap the current functions.

"I can't believe I'm defending logic to a turing machine." - Kent Woolworth [Other Space]

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