小编ode*_*dsh的帖子

使用c ++ 11编译时,Mingw g ++无法识别off_t

我写过最小的测试问题:

#include <sys/types.h>
int main(int argc, char** argv) {
    off_t l = 0;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

以下作品: g++ test.cpp

但如果我尝试使用c ++ 11进行编译,我会得到:

c:\ test> g ++ -std = c ++ 11 test.cpp

test.cpp: In function 'int main(int, char**)':
test.cpp:5:2: error: 'off_t' was not declared in this scope
test.cpp:5:8: error: expected ';' before 'l'
test.cpp:6:9: error: 'l' was not declared in this scope
Run Code Online (Sandbox Code Playgroud)

任何人都可以解释为什么会这样?这困扰我的原因是我试图在我的c ++ 11代码中使用zlib库.库zlib.h使用off_t很多.

我的编译器版本是:gcc 4.7.2

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.7.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.7.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 …
Run Code Online (Sandbox Code Playgroud)

c++ mingw mingw32 c++11

5
推荐指数
1
解决办法
2330
查看次数

标签 统计

c++ ×1

c++11 ×1

mingw ×1

mingw32 ×1