• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problem with #include <unistd.h> - 'close' was not declared
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with #include <unistd.h> - 'close' was not declared


  • Subject: Re: Problem with #include <unistd.h> - 'close' was not declared
  • From: "Tom O'Grady" <email@hidden>
  • Date: Tue, 20 Nov 2007 13:39:49 -0000

Hi Alistair,
Thanks for your assistance.
I determined which file was being included by copying the 10.4u SDK to my desktop so I had an editable copy, linking to that instead, and inserting 'ERROR' or something similar into the header files of interest.
I'll try to check out that windows / non-windows issue out. I've also found that in ap_config.h:


#ifndef BEOS
#define closesocket(s) close(s)
#endif

The stdafx.h point is noted - I'm mainly involved with porting applications from PC to Mac, so it usually works out ok sharing a stdafx.h file but wrapping the platform-specific stuff in #if WIN32 etc. The files are shared so if I was using a different header / prefix header, it might be a headache to keep both up-to-date for every single project (i.e. when the other guy modifies his side but doesn't tell me, or vice versa). I think I can just #include my stdafx.h in my prefix header if i want it to be precompiled like that...?
thanks,
Tom


On 20 Nov 2007, at 09:13, Tom O'Grady wrote:

I have the line '#include <unistd.h>' in my stdafx.h but I get an error saying that: 'close' was not declared in this scope. And it seems that "usr/include/sys/unistd.h" is being found rather than the "usr/include/unistd.h" which is intended.
I don't know what other information to supply, but if there are any build settings that might give anybody a clue as to how to solve this problem, please let me know and I'll post them too.

Hi Tom,

You don't say how you determined that "/usr/include/sys/unistd.h" was being included instead of "/usr/include/unistd.h".

One of the most common causes of problems with close() in mixed Windows/non-Windows sockets code is that some smart-alec has #defined close() in one of the program's headers so that it calls closesocket() instead. My guess is that this is actually what your problem is here, and that it looks like it's being fixed when you manually include /usr/ include/unistd.h because of where you're writing the extra #include line.

Another thing to note (if you haven't already realised; I assume you must have, but I imagine that this is a common problem also) is that "stdafx.h" is a Microsoft-ism. It's broadly equivalent to Xcode/GCC's "Prefix headers" feature, but there is no general equivalent in the C, C++ or ObjC languages so if you plan on being portable to other systems you may want to restrict usage of this feature to platform- specific files.

Kind regards,

Alastair.

--
http://alastairs-place.net





_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Problem with #include <unistd.h> - 'close' was not declared
      • From: Alastair Houghton <email@hidden>
References: 
 >Problem with #include <unistd.h> - 'close' was not declared (From: "Tom O'Grady" <email@hidden>)
 >Re: Problem with #include <unistd.h> - 'close' was not declared (From: Alastair Houghton <email@hidden>)

  • Prev by Date: Proper way to compile static libraries into projects?
  • Next by Date: Re: Proper way to compile static libraries into projects?
  • Previous by thread: Re: Problem with #include <unistd.h> - 'close' was not declared
  • Next by thread: Re: Problem with #include <unistd.h> - 'close' was not declared
  • Index(es):
    • Date
    • Thread