'ptrdiff_t' has not been declared

J

jubelbrus

I'm getting the following error, and from 40 to 300 similar error when
I try to compile on mac os x.

I believe that it has something to do with STL, because this error
occures when I try to include any STL files, like list in this
example.

Please help me.

c++ code:
#include <cstddef>
#include <cstdlib>
#include <list>

int main()
{
return EXIT_SUCCESS;
}

Compile command (from xcode):
/usr/bin/gcc-4.0 -x c++ -arch i386 -pipe -Wno-trigraphs -fasm-
blocks -g -O0 -fmessage-length=0 -mfix-and-continue -mmacosx-version-
min=10.4 -fvisibility-inlines-hidden -I/Users/thomas/Development/xcode/
mwcd_development/build/mwcd_development.build/Debug/Tester.build/
Tester.hmap -F/Users/thomas/Development/xcode/mwcd_development/build/
Debug -I/Users/thomas/Development/xcode/mwcd_development/build/Debug/
include -I/Users/thomas/Development/xcode/mwcd_development/build/
mwcd_development.build/Debug/Tester.build/DerivedSources -isysroot /
Developer/SDKs/MacOSX10.4u.sdk -c /Users/thomas/Development/xcode/
mwcd_development/tester_a.cpp -o /Users/thomas/Development/xcode/
mwcd_development/build/mwcd_development.build/Debug/Tester.build/
Objects-normal/i386/tester_a.o

Output:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/cstddef:52:
error: '::ptrdiff_t' has not been declared
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/cstddef:53:
error: '::size_t' has not been declared
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/postypes.h:
78: error: 'ptrdiff_t' does not name a type
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_iterator_base_types.h:104: error: expected type-specifier before
'ptrdiff_t'
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_iterator_base_types.h:104: error: expected `>' before 'ptrdiff_t'
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_iterator_base_types.h:115: error: '_Pointer' does not name a type
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_iterator_base_types.h:117: error: '_Reference' does not name a
type
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_iterator_base_types.h:141: error: 'ptrdiff_t' does not name a type
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_iterator_base_types.h:151: error: 'ptrdiff_t' does not name a type
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_iterator.h:95: error: wrong number of template arguments (5,
should be 3)
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_iterator_base_types.h:106: error: provided for 'template<class
_Category, class _Tp, class _Distance> struct std::iterator'
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_iterator.h:337: error: wrong number of template arguments (5,
should be 3)
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_iterator_base_types.h:106: error: provided for 'template<class
_Category, class _Tp, class _Distance> struct std::iterator'
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_iterator.h:412: error: wrong number of template arguments (5,
should be 3)
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_iterator_base_types.h:106: error: provided for 'template<class
_Category, class _Tp, class _Distance> struct std::iterator'
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_iterator.h:490: error: wrong number of template arguments (5,
should be 3)
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_iterator_base_types.h:106: error: provided for 'template<class
_Category, class _Tp, class _Distance> struct std::iterator'
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_algobase.h: In static member function 'static _Tp*
std::__copy_backward<true,
std::random_access_iterator_tag>::copy_b(const _Tp*, const _Tp*,
_Tp*)':
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_algobase.h:424: error: 'ptrdiff_t' does not name a type
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_algobase.h:425: error: '_Num' was not declared in this scope
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/new: At global
scope:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/new:84: error:
declaration of 'operator new' as non-function
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/new:84: error:
'size_t' is not a member of 'std'
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/new:85: error:
declaration of 'operator new []' as non-function
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/new:85: error:
'size_t' is not a member of 'std'
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/new:88: error:
declaration of 'operator new' as non-function
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/new:88: error:
'size_t' is not a member of 'std'
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/new:88: error:
expected primary-expression before 'const'
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/new:89: error:
declaration of 'operator new []' as non-function
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/new:89: error:
'size_t' is not a member of 'std'
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/new:89: error:
expected primary-expression before 'const'
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/new:94: error:
declaration of 'operator new' as non-function
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/new:94: error:
'size_t' is not a member of 'std'
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/new:94: error:
expected primary-expression before 'void'
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/new:95: error:
declaration of 'operator new []' as non-function
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/new:95: error:
'size_t' is not a member of 'std'
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/new:95: error:
expected primary-expression before 'void'
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/ext/
new_allocator.h:54: error: 'ptrdiff_t' does not name a type
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/allocator.h:
65: error: 'ptrdiff_t' does not name a type
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/allocator.h:
86: error: 'ptrdiff_t' does not name a type
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/stl_list.h:
116: error: 'ptrdiff_t' does not name a type
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/stl_list.h:
193: error: 'ptrdiff_t' does not name a type
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/stl_list.h:
409: error: 'ptrdiff_t' does not name a type
 
O

osmium

jubelbrus said:
I'm getting the following error, and from 40 to 300 similar error when
I try to compile on mac os x.

I believe that it has something to do with STL, because this error
occures when I try to include any STL files, like list in this
example.

Please help me.

c++ code:
#include <cstddef>
#include <cstdlib>
#include <list>

int main()
{
return EXIT_SUCCESS;

I would start by changing that to std::EXIT_SUCCESS;
 
V

Victor Bazarov

jubelbrus said:
[..]
Compile command (from xcode):
/usr/bin/gcc-4.0 -x c++ [..]

Output:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/cstddef:52:
error: '::ptrdiff_t' has not been declared
[..]

Ask in a gnu newsgroup, they apparently have something to do with it;
your code compiles fine on my system (as it should).

V
 
V

Victor Bazarov

osmium said:
I would start by changing that to std::EXIT_SUCCESS;

Really? How does putting "std::" in front of a macro help? It's
similar to writing "std::NULL", do you use that as well? I am
genuinely curious, maybe I am missing something obvious in my work.

Thanks!

V
 
O

osmium

Victor Bazarov said:
Really? How does putting "std::" in front of a macro help? It's
similar to writing "std::NULL", do you use that as well? I am
genuinely curious, maybe I am missing something obvious in my work.

I think I messed up. What's your guess?
 
J

jubelbrus

No guesses here, I was just asking.

V

Found the problem. Had something to with the setup of the build in
xcode.
Removed "Always search user paths", and like magic, everything worked.

By the way, thanks for all the replies
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,048
Members
48,769
Latest member
Clifft

Latest Threads

Top