TEST.CPP
#include <cstdio>
#include <cstddef>
using std::size_t;
编译:
> g++ -c test.cpp -o test.o
In file included from /.../include/stdio.h:75:0,
from /.../gcc/include/c++/cstdio:42,
from test.cpp:1:
test.cpp:3:12: error: expected unqualified-id before ‘int’
using std::size_t;
^
test.cpp:3:12: error: expected ‘;’ before ‘int’
test.cpp:3:12: error: declaration does not declare anything [-fpermissive]
如果我只删除#include <cstdio>
,一切正常
但如果我只删除#include <cstddef>
,则会弹出相同的错误
如果我删除了两个:
> g++ -c test.cpp -o test.o
test.cpp:1:12: error: ‘std::size_t’ has not been declared
using std::size_t;
^
我需要包含两个库,以及要使用的std::size_t
在这种情况下我该怎么办?我应该添加一些CXXFLAGS
吗?
我的gcc版本是4.8.5。
> g++ --version
g++ (GCC) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
更新:
我已经尝试过系统的默认gcc:/usr/bin/g++
,错误消失了
所以它应该是anaconda的gcc责任。我将向小组提出一个问题
谢谢大家。