• 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
Problem with #include <unistd.h> - 'close' was not declared
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


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

Hi,
yes those typos were just transcription errors - the Mac I was working from was not connected to this PC with Synergy so I had to write it out by hand. Here are my includes:


#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

The project builds a static library containing some network calls we require. I have a 'socketbase' class which contains a protected member 'int' called 'mySocket'. There are ReadData / SendData functions which use the BSD functions 'send' and 'recv' (from 'socket.h') which compile fine. however, the destructor looks like this:


COurSocketBase::~COurSocketBase()
{
   if (mySocket)
   {
#ifdef WIN32
       closesocket(mySocket);
#else
       close(mySocket);
#endif
   }
}

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.
Thanks,
Tom


Date: Mon, 19 Nov 2007 08:59:04 -0800
From: "Justin C. Walker" <email@hidden>
Subject: Re: Problem with #include <unistd.h> - 'close' was not
declared in this scope
To: Xcode Users <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed

Hi,

On Nov 19, 2007, at 08:03 , Tom O'Grady wrote:

I'm trying to use the 'close' function used for file descriptors
etc, but even when I have the line '#include <unistd.h>', I get the
message:

'close' was not declared in this scope.

The Xcode project includes some code involving sockets. The list of
included headers is as follows:

#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types/h>
#include <sys/uio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa.inet.h>
[snip]
my Xcode project includes the file '$(SDKROOT)/usr/include/usr/
unistd.h'

I assume you typed the above in by hand (there several typos), but in any case, without a minimal example, it's not clear what's going wrong; and it's not easy to read your mind at this distance. I've not seen this error in this context before.

'#include "usr/include/unistd.h" '

You're right that this is the wrong solution.

Justin

--
Justin C. Walker, Curmudgeon-At-Large
Institute for the Enhancement of the Director's Income
--------
When LuteFisk is outlawed,
Only outlaws will have LuteFisk
--------

Date: Mon, 19 Nov 2007 16:03:17 -0000
From: "Tom O'Grady" <email@hidden>
Subject: Problem with #include <unistd.h> - 'close' was not declared
in this scope
To: <email@hidden>
Message-ID: <001f01c82ac5$b2d7a520$ed02a8c0@Geronimo>
Content-Type: text/plain; charset="iso-8859-1"

Hi there,
I have a problem which I'd be very grateful for some help with...

I'm trying to use the 'close' function used for file descriptors etc, but even when I have the line '#include <unistd.h>', I get the message:

'close' was not declared in this scope.

The Xcode project includes some code involving sockets. The list of included headers is as follows:

#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types/h>
#include <sys/uio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa.inet.h>

The calls to 'socket', 'recv' etc compile fine - it's just the problem with 'close'.
My SDKROOT variable is set to /Developer/SDKs/MacOSX10.4u.sdk/
I tried linking to an editable copy of the 10.4u SDK I'd placed on my Desktop, and by adding lines to cause errors, it seems that when interpreting the line:


#include <unistd.h>

my Xcode project includes the file '$(SDKROOT)/usr/include/usr/unistd.h'

instead of the one where 'close' is defined which I need: $(SDKROOT)/usr/include/unistd.h' (which includes the one above anyway).

I don't have any special header search paths relating to the SDK - only paths to our own code.
A temporary measure is to substitute the line:


'#include "usr/include/unistd.h" '

since this removes the error, but this is probably the wrong way to go about it, since it just sweeps the problem under the carpet...


Could anybody suggest what I need to do to solve this?

Thanks,
Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.apple.com/pipermail/xcode-users/attachments/20071119/0c18617d/attachment.html






_______________________________________________
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>
  • Prev by Date: Re: run log in Xcode 3
  • Next by Date: Xcode 3 incorrect 'Incompatible Service' in dist. builds?
  • Previous by thread: run log in Xcode 3
  • Next by thread: Re: Problem with #include <unistd.h> - 'close' was not declared
  • Index(es):
    • Date
    • Thread