DaVinci
DaVinci

Reputation: 1391

_stricmp with mingw and c++0x not existent?

I'm currently trying to use googletest with MinGW and -std=c++0x but it complains that _stricmp is not declared in this scope which it doesn't when I do not use -std=c++0x. I have no idea what _stricmp is, I just found out that it is defined in cstring/string.h, so why is it gone in C++0x?

Upvotes: 21

Views: 9990

Answers (4)

Karol Stola
Karol Stola

Reputation: 21

I've had the exact same issue, but for me it was, that I've had a file String.h in an include path, that was picked up by the proprocessor and used instead of the standard one. Found thanks to this thread.

Upvotes: 0

kszyniu
kszyniu

Reputation: 91

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.

Upvotes: 1

Yuriy Petrovskiy
Yuriy Petrovskiy

Reputation: 8188

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.

Upvotes: 7

Michael Burr
Michael Burr

Reputation: 340446

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.

Upvotes: 24

Related Questions