Jump to content
  • Advertisement
Sign in to follow this  
Rattrap

gcc problem

This topic is 4054 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Maybe I missed something but why don't you use operator overloading instead of making functions with the operator names?

Share this post


Link to post
Share on other sites
I'm going to have overloaded operators when it's done. They are just going to wrap the current functions.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!