Mingw won't compile because "isblank" was not declared in this area "

I am trying to compile and link the following program with mingw. When I use the default version it works well. But when I use the C ++ 11 version it doesn't compile and gives me the following error newfile.cpp:22:18: error: 'isblank' was not declared in this scope

. to test the following program, it is enough to call the function _isblank

basically.

NetBeans 8.0.2 uses the g++ -c -g -Wall -std=c++11 -MMD -MP -MF "build/Debug/MinGW_1-Windows/newfile.o.d" -o build/Debug/MinGW_1-Windows/newfile.o newfile.cpp

.

The mingw version is 4.8.1 and everything is set up well (default).

I tried adding / removing the std namespace. The problem seems to be in the cctype header! But I am wondering how to solve it. The project must be compiled with g ++ on Linux! Will these problems remain?

#include <cstdlib>
#include <cctype>
#include <fstream>
#include <sstream>
#include <string>
#include <iostream>
#include <map>
#include <functional>
#include "newfile.h"

using namespace std;
conf_info_t CONF_INFO;

#define CONF_FILE_ADDRESS "confs.txt"
//
//typedef std::map<std::string, std::function<void (const std::string&)>> confMap_t;
//confMap_t confMap;

int _isblank(int c){
    return isblank(c);
    //return c == ' ' || c == '\t';
}

      

+3


source to share


2 answers


In my version of the GNU Library, the isblank

in header declaration <ctype.h>

is protected by some conditional compilation directives, which should nevertheless make this function available in C ++.

However, in the title, <cctype>

this function is separated from all other ads and receives special treatment for some reason. It is only available in the namespace std

if a macro is specified _GLIBCXX_USE_C99_CTYPE_TR1

. This is what looks like inside<cctype>

#if __cplusplus >= 201103L

#ifdef _GLIBCXX_USE_C99_CTYPE_TR1

#undef isblank

namespace std
{
  using ::isblank;
} // namespace std

#endif // _GLIBCXX_USE_C99_CTYPE_TR1

#endif // C++11

      



I don't know what is the purpose a macro should serve _GLIBCXX_USE_C99_CTYPE_TR1

. In my GCC installation, this macro is defined, which makes it isblank

available in my case.

You might want to check what yours looks like <cctype>

and see if something like this happens on your side.

+2


source


It worked when I undefined STRICT_ANSI in the translation block by adding -U__STRICT_ANSI__ to the compiler options. But I'm wondering what part of my program violates C ++ standards.

It should be compiled like this:



g++ -U__STRICT_ANSI__   -c -g -Wall -std=c++11 -MMD -MP -MF "build/Debug/MinGW_1-Windows/main.o.d" -o build/Debug/MinGW_1-Windows/main.o main.cpp

      

+1


source







All Articles