[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: automake
From: |
Ralf Wildenhues |
Subject: |
Re: automake |
Date: |
Fri, 25 Nov 2005 08:48:47 +0100 |
User-agent: |
Mutt/1.5.11 |
Hi Adnan,
* Adnan Shaheen wrote on Fri, Nov 25, 2005 at 06:59:16AM CET:
> Well I am writting some code, you tell me what should the compiler do when I
> compile it.
> As earlier I told you about I am working on a LINUX machine.
>
> CODE:
>
> #ifdef LINUX
> #include <sys/socket.h>
> #else // !(LINUX)
> #include <winsock.h>
> #endif // LINUX
>
> END
Autoconf-style for this would be to add
AC_CHECK_HEADERS([sys/socket.h winsock.h])
to configure.ac, and to change your code like this: Put
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
at the very top of your .c files (this is so the code works whether you
use AC_CONFIG_HEADERS or not), and change above snippet to
#include <stdlib.h>
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_WINSOCK_H
# include <winsock.h>
#endif
The Autoconf manual notes that stdlib.h should be included before
sys/socket.h for Darwin.
> I think you understand this simple code, I want to open the socket.h header
> when I am under LINUX and winsock.h header when I am working on the WINDOWS
> machine. So what the compiler did to me, is that, it was trying to open the
> winsock.h header instead of socket.h.
>
> As when I wrote the makefile mannually, It works fine.
That's likely because your manual makefile defines LINUX somewhere, and
the automake-generated one doesn't. It's not necessary, though, see
above.
Cheers,
Ralf