473,670 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

'ptrdiff_t' has not been declared

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_developmen t/build/mwcd_developmen t.build/Debug/Tester.build/
Tester.hmap -F/Users/thomas/Development/xcode/mwcd_developmen t/build/
Debug -I/Users/thomas/Development/xcode/mwcd_developmen t/build/Debug/
include -I/Users/thomas/Development/xcode/mwcd_developmen t/build/
mwcd_developmen t.build/Debug/Tester.build/DerivedSources -isysroot /
Developer/SDKs/MacOSX10.4u.sdk -c /Users/thomas/Development/xcode/
mwcd_developmen t/tester_a.cpp -o /Users/thomas/Development/xcode/
mwcd_developmen t/build/mwcd_developmen t.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_ba se_types.h:104: error: expected type-specifier before
'ptrdiff_t'
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_iterator_ba se_types.h:104: error: expected `>' before 'ptrdiff_t'
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_iterator_ba se_types.h:115: error: '_Pointer' does not name a type
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_iterator_ba se_types.h:117: error: '_Reference' does not name a
type
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/c++/4.0.0/bits/
stl_iterator_ba se_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_ba se_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_ba se_types.h:106: error: provided for 'template<class
_Category, class _Tp, class _Distancestruct 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_ba se_types.h:106: error: provided for 'template<class
_Category, class _Tp, class _Distancestruct 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_ba se_types.h:106: error: provided for 'template<class
_Category, class _Tp, class _Distancestruct 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_ba se_types.h:106: error: provided for 'template<class
_Category, class _Tp, class _Distancestruct 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_bac kward<true,
std::random_acc ess_iterator_ta g>::copy_b(cons t _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

Jun 15 '07 #1
6 14012
"jubelbrus" writes:
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_SUCCE SS;
}

Jun 15 '07 #2
jubelbrus wrote:
[..]
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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 15 '07 #3
osmium wrote:
"jubelbrus" writes:
>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_SUCCE SS;
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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 15 '07 #4
"Victor Bazarov" writes:
osmium wrote:
>> return EXIT_SUCCESS;

I would start by changing that to std::EXIT_SUCCE SS;

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?
Jun 15 '07 #5
osmium wrote:
"Victor Bazarov" writes:
>osmium wrote:
>>> return EXIT_SUCCESS;

I would start by changing that to std::EXIT_SUCCE SS;

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?
No guesses here, I was just asking.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 15 '07 #6
On 15 Jun, 15:12, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
osmium wrote:
"Victor Bazarov" writes:
osmium wrote:
return EXIT_SUCCESS;
>I would start by changing that to std::EXIT_SUCCE SS;
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?

No guesses here, I was just asking.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
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

Jun 16 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4561
by: PengYu.UT | last post by:
I'm wondering when I should use ptrdiff_t and size_t instead of int and unsigned int or long and unsigned long? Is there any guideline I should follow? Peng
9
3091
by: PengYu.UT | last post by:
std::size_t and std::ptrdiff_t are defined in <cstddef>. I've noticed that a bunch of old math function in the global namespace are undefined in <cmath> and they are redefined in std namespace. I'm wondering why ::size_t and ::ptrdiff_t aren't undefined. Thanks, Peng
2
1644
by: alberto | last post by:
I am learning STL with the book STL Tutorial and Reference guide (1 edition), the following example don't run : int main() { // Initialize array a with 10 integers: int a = {12, 3, 25, 7, 11, 213, 7, 123, 29, -31}; // Find the first element equal to 7 in the array: int* ptr = find(&a, &a, 7);
26
6695
by: robertwessel2 | last post by:
In another thread, a poster mentioned the Posix ssize_t definition (signed version of size_t). My initial reaction was to wonder what the point of the Posix definition was when ptrdiff_t was already defined as such. I got the idea that ptrdiff_t had to be the same size as size_t from Plauger's "The Standard C Library," where he states "... It is always the signed type that has the same number of bits as the4 unsigned type chosen for...
10
3494
by: kyagrd | last post by:
<code> #include <iostream> int main(void) { using namespace std; int p; int* p1 = p; int* p11 = p + 2;
0
8471
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8388
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8907
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8593
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8663
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6218
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4396
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2804
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.