Author Topic: [MinGW] or and not interpreted as || and !  (Read 6164 times)

Offline MoonKid

  • Almost regular
  • **
  • Posts: 180
[MinGW] or and not interpreted as || and !
« on: May 28, 2007, 02:46:11 pm »
I am using Code::Blocks on WinXP with MinGW gcc.

I have a foreign project and try to compile it.
There is this piece of code

SEARCHPGM {         /* search program */
  SEARCHSET *msgno;      /* message numbers */
  SEARCHSET *uid;      /* unique identifiers */
  SEARCHOR *or;         /* or'ed in programs */
  SEARCHPGMLIST *not;      /* and'ed not program */
  SEARCHHEADER *header;      /* list of headers */
  STRINGLIST *bcc;      /* bcc recipients */

Look at '*or' and '*not'. I am not sure but I think the compiler interpret it as '*||' and '*!' what have to occure an error of course. This is the error:

In file included from include/Mcclient.h:24,
                 from D:\Garage\projekte\mahogany\mahoganySVN\src\classes\MApplication.cpp:30:
lib/imap/src/c-client/mail.h:933: error: expected unqualified-id before '||' token
lib/imap/src/c-client/mail.h:933: error: abstract declarator `search_or*' used as declaration
lib/imap/src/c-client/mail.h:933: error: expected `;' before '||' token
lib/imap/src/c-client/mail.h:934: error: expected unqualified-id before '!' token
lib/imap/src/c-client/mail.h:934: error: abstract declarator `search_pgm_list*' used as declaration
lib/imap/src/c-client/mail.h:934: error: expected `;' before '!' token
In file included from D:\Garage\projekte\mahogany\mahoganySVN\src\classes\MApplication.cpp:30:

Is it C++ standard to interpret or and not as the operators? If not, how can I turn that off?

The code works fine on MSVC.

Offline Deschamps

  • Multiple posting newcomer
  • *
  • Posts: 120
Re: [MinGW] or and not interpreted as || and !
« Reply #1 on: May 28, 2007, 04:55:03 pm »
Quote
Is it C++ standard to interpret or and not as the operators? If not, how can I turn that off?

AFAIK, "or" and "not" are compiled as operators, at least within gcc (edit: for g++, i.e. not in C but in C++). No idea on how to avoid it, but i think that the easiest way is "search and replace in files" and use another identifiers (initial capital or final underscore, for instance).

Quote
The code works fine on MSVC

 :shock: Does it work fine or simply compiles without errors?
« Last Edit: May 28, 2007, 05:07:34 pm by Deschamps »
Those who were seen dancing were thought to be insane by those who could not hear the music

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: [MinGW] or and not interpreted as || and !
« Reply #2 on: May 28, 2007, 06:07:51 pm »
http://cs.smu.ca/~porter/csc/ref/cpp_keywords.html

In any case, I think it's a bad idea to use such keywords for identifiers. Microsoft has a long historial of being too soft on programmers, and that leads to errors like this one.