libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] build errors.


From: luis garcia
Subject: Re: [libmicrohttpd] build errors.
Date: Mon, 15 Oct 2012 15:41:11 -0700

I think my assumption that plibc is only used for windows might not be correct given that when I define HAVE_PLIBC_H to 0 there are functions that are only defined in this library that is still being called by the code.

My current solution to the build problem is to modify daemon.c to always use #ifdef or #ifndef WINDOWS instead of #if. Using this method I am able to build the library and plibc.h works well since this is their default mechanism.

I hope a solution is made to the library source code so my code does not deviate from it.

Thanks again for any attention to this issue.

Luis

On Mon, Oct 15, 2012 at 3:19 PM, luis garcia <address@hidden> wrote:
Hi,

When I compile the library with the c compiler instead of c++ i get errors due to mix use of #if and #ifdef WINDOWS.

I will give an example. I compile the library for Linux environment. If I try to compile having WINDOWS undefined the build will failed whenever daemon.c expects WINDOWS to be defined. Here are couple examples:

    /* make socket non-inheritable */
#if WINDOWS
    DWORD dwFlags;
and

#if !WINDOWS
  flags = fcntl (fd, F_GETFD);
  if (flags < 0)
among others.

So then I proceed to define WINDOWS to 0 in MHD_config.h
#define WINDOWS 0

Although this does not cause build problems in daemon.c there are issues since now WINDOWS is defined. Therefore code like the one below will act as if the library was built for WINDOWS:

#ifdef IPV6_V6ONLY
	  /* Note: "IPV6_V6ONLY" is declared by Windows Vista ff., see "IPPROTO_IPV6 Socket Options" 
	     (http://msdn.microsoft.com/en-us/library/ms738574%28v=VS.85%29.aspx); 
	     and may also be missing on older POSIX systems; good luck if you have any of those,
	     your IPv6 socket may then also bind against IPv4... */
#ifndef WINDOWS
	  const int on = 1;
	  setsockopt (socket_fd, 
		      IPPROTO_IPV6, IPV6_V6ONLY, 
		      &on, sizeof (on));
#else
	  const char on = 1;
	  setsockopt (socket_fd, 
		      IPPROTO_IPV6, IPV6_V6ONLY, 
		      &on, sizeof (on));
#endif
#endif
and

/**
 * Default connection limit.
 */
#ifndef WINDOWS
#define MHD_MAX_CONNECTIONS_DEFAULT FD_SETSIZE - 4
#else
#define MHD_MAX_CONNECTIONS_DEFAULT FD_SETSIZE
#endif

Finally plibc.h uses #ifdef WINDOWS and if WINDOWS is defined even to 0 it assumes that you are using windows. Which will cause a whole set of issues when you are not actually targeting windows. Looking at the code I realized that plibc is only intended to be used and compiled when targeting windows, but confirmation of this will be appreciated.

Thanks for any comments on this matter.

Luis




reply via email to

[Prev in Thread] Current Thread [Next in Thread]