2

test.cpp

#include <cstdio>
#include <cstddef>
using std::size_t;

To compile:

 >  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]

If I only remove #include <cstdio>, everything works fine.
But If I only remove #include <cstddef>, the same error pops up.
If I remove both:

 >  g++ -c test.cpp -o test.o    
test.cpp:1:12: error: ‘std::size_t’ has not been declared
 using std::size_t;
            ^

I need both libraries to be included, as well as std::size_t to be used.
What should I in this situation? Should I add some CXXFLAGS?

My gcc version is 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.

UPDATE:

I have tried system's default gcc: /usr/bin/g++, the error is gone.
So it should be anaconda's gcc to blame. I will raise an issue to the group.
Thank you all.

Panwen Wang
  • 1,889
  • 11
  • 25

0 Answers0