autoconf
[Top][All Lists]
Advanced

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

Re: can autoconf determine if a preprocessor macro is defined or not?


From: Keith MARSHALL
Subject: Re: can autoconf determine if a preprocessor macro is defined or not?
Date: Thu, 27 Jul 2006 14:18:48 +0100

Ed Hartnett wrote:
> Here's what I had to add to get my code to build. I would prefer
> if autoconf could add this to config.h, for example:
>
> /* These are needed on mingw to get a dll to compile. They really
>  * should be provided in sys/stats.h, but what the heck. Let's not
>  * be too picky! */
> #ifndef S_IRGRP
> #define S_IRGRP   0000040
> #endif
> #ifndef S_IROTH
> #define S_IROTH   0000004
> #endif
> #ifndef S_IWGRP
> #define S_IWGRP   0000020
> #endif
> #ifndef S_IWOTH
> #define S_IWOTH   0000002
> #endif

I'm curious as to why you would expect MinGW's `sys/stat.h' to
define these?

MinGW specifically targets the *native* Win32 platform.  These are
*UNIX* specific filesystem attributes; they are *not* supported in
native Win32.

By defining them, you fool the compiler into believing that the OS
supports features that it doesn't.  MinGW *deliberately* omits these
defines, so you get a compile time error when you try to do something
which the OS doesn't support.  By sidestepping this, you leave your
application vulnerable to unexpected behaviour, or even failure at
runtime; defining them is *not* a good idea.

What you should be doing is recognising that these don't apply on
the host OS, and coding so that you don't use them.  When compiling
for a host such as Win32, use something like `#ifdef _WIN32', (or,
for a MinGW specific test, `#ifdef __MINGW32__'), to identify these
special cases, and provide alternative code which doesn't use
these unsupported attributes.

Regards,
Keith.




reply via email to

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