【发布时间】:2015-01-13 16:34:44
【问题描述】:
我尝试用 mingw 编译和链接以下程序。当我使用默认版本时,它运行良好。但是当我使用 c++11 版本时,它不会编译并给我以下错误newfile.cpp:22:18: error: 'isblank' was not declared in this scope。
为了测试下面的程序,在 main 中调用 _isblank 函数就足够了。
对于编译 Netbeans 8.0.2 使用 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。
mingw 版本是 4.8.1,一切都配置好(默认)。
我尝试通过添加/删除命名空间标准。问题似乎出在 cctype 标头中!但我想知道如何解决它。该项目必须在 linux 上使用 g++ 编译!这些问题还会存在吗?
#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';
}
【问题讨论】:
-
您是否尝试递归调用_isblank?
-
当然!我写了 _isblank 是因为 isblank 在 std=c++11 程序中的任何地方都不起作用,但我无法重新发明所有库函数,因为编译器找不到它们!
-
通常以下划线开头的函数是为编译器或库实现保留的。您是否尝试过 grepping MinGW 包含 isblank 的标头?
-
我也尝试了 istDasBlank() 但没有区别