Domanda

Al momento sto cercando di utilizzare googletest con MinGW e -std=c++0x ma lamenta che _stricmp is not declared in this scope che non quando non utilizzare -std=c++0x. Non ho idea di quello che è _stricmp, ho appena scoperto che è definito in cstring/string.h, quindi perché è andato in C ++ 0x?

È stato utile?

Soluzione

The -std=c++0x option causes g++ to go into 'strict ANSI' mode so it doesn't declare non-standard functions (and _stricmp() is non-standard - it's just a version of strcmp() that's case-insensitive).

Use -std=gnu++0x instead.

Altri suggerimenti

In addition to solution by Michael there is other method for overriding strict ANSI mode. Include the following before any includes in file with compilation problems:

#ifdef __STRICT_ANSI__
#undef __STRICT_ANSI__
#endif

This helps not only with _stricmp also with other common functions like swptintf, vswprintf and simmilar.

You can take a look at MinGW-w64, which allowed me to run Google Tests with -std=c++11 (works with your -std=c++0x as well). It eliminates problems with _stricmp, _strdup and so forth.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top