emacs-devel
[Top][All Lists]
Advanced

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

Latest EMACS on BZR trunk does not compile with MinGW


From: Vincent Belaïche
Subject: Latest EMACS on BZR trunk does not compile with MinGW
Date: Tue, 03 Jun 2014 22:00:02 +0200

Here is what I get:

dup2.c:35:0: warning: "WIN32_LEAN_AND_MEAN" redefined [enabled by default]
c:/Programme/GNU/installation/emacs-install/emacs/trunk/nt/inc/ms-w32.h:148:0: 
note: this is the location of the previous definition
dup2.c:38:26: fatal error: msvc-inval.h: No such file or directory
compilation terminated.


msvc-inval.h, given its naming, is probably a file from the MS Visual C
compiler suite, it seems that it is not available with MinGW --- at
least with the version of the gcc suite installed on my machine.

Here is the problematic piece of code from dup2.c:

-----------------------------------------------------------------------
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__

/* Get declarations of the native Windows API functions.  */
#  define WIN32_LEAN_AND_MEAN
#  include <windows.h>

#  include "msvc-inval.h"

/* Get _get_osfhandle.  */
#  include "msvc-nothrow.h"

static int
ms_windows_dup2 (int fd, int desired_fd)
{
  int result;

  /* If fd is closed, mingw hangs on dup2 (fd, fd).  If fd is open,
     dup2 (fd, fd) returns 0, but all further attempts to use fd in
     future dup2 calls will hang.  */
  if (fd == desired_fd)
    {
      if ((HANDLE) _get_osfhandle (fd) == INVALID_HANDLE_VALUE)
        {
          errno = EBADF;
          return -1;
        }
      return fd;
    }

  /* Wine 1.0.1 return 0 when desired_fd is negative but not -1:
     http://bugs.winehq.org/show_bug.cgi?id=21289 */
  if (desired_fd < 0)
    {
      errno = EBADF;
      return -1;
    }

  TRY_MSVC_INVAL
    {
      result = dup2 (fd, desired_fd);
    }
  CATCH_MSVC_INVAL
    {
      errno = EBADF;
      result = -1;
    }
  DONE_MSVC_INVAL;

  if (result == 0)
    result = desired_fd;

  return result;
}

#  define dup2 ms_windows_dup2

# endif
-----------------------------------------------------------------------

Maybe the  

 `&& ! defined __CYGWIN__'

wherever used in this file for this topic should be replaced by

`&& defined _MSC_VER' 

or something like that --- I cannot remember exactly the #definition
that one can use to detect MSVC compiler.

An alternative would be to use

`&& ! defined __CYGWIN__ && ! defined __MINGW32__'

but well, if the msvc_xxx.h file are MSVC specific, I would prefer the
other one.

VBR,
   Vincent.



reply via email to

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