Re: [PATCH 08/14] help.c: Fix detection of custom merge strategy on cygwin

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

 



On Thu, Dec 16, 2010 at 10:03 PM, Ramsay Jones
<ramsay@xxxxxxxxxxxxxxxxxxx> wrote:
> Erik Faye-Lund wrote:
>>> diff --git a/help.c b/help.c
>>> index 7f4928e..eabadc9 100644
>>> --- a/help.c
>>> +++ b/help.c
>>> @@ -126,7 +126,10 @@ static int is_executable(const char *name)
>>>            !S_ISREG(st.st_mode))
>>>                return 0;
>>>
>>> -#ifdef WIN32
>>> +#if defined(WIN32) || defined(__CYGWIN__)
>>> +#if defined(__CYGWIN__)
>>> +if ((st.st_mode & S_IXUSR) == 0)
>>> +#endif
>>
>> Perhaps the first check should simply be changed to check for _WIN32
>> instead of WIN32? IIRC _WIN32 is set on Cygwin, but I could be
>> mistaken...
>
> No, neither WIN32 or _WIN32 will be defined here (and they should not be).
> It's actually quite tricky, particularly when #including <windows.h>, viz:
>
>    $ cat -n test.c
>     1  #include <stdio.h>
>     2
>     3  #ifdef IW
>     4  # include <windows.h>
>     5  #endif
>     6
>     7  int main(int argc, char *argv[])
>     8  {
>     9  #ifdef WIN32
>    10          printf("WIN32 ");
>    11  #endif
>    12  #ifdef _WIN32
>    13          printf("_WIN32 ");
>    14  #endif
>    15  #ifdef __CYGWIN__
>    16          printf("__CYGWIN__ ");
>    17  #endif
>    18  #ifdef __MINGW32__
>    19          printf("__MINGW32__ ");
>    20  #endif
>    21          printf("\n");
>    22          return 0;
>    23  }
>
>    $ gcc -o test test.c
>    $ ./test
>    __CYGWIN__
>
>    $ gcc -o test -DIW test.c
>    $ ./test
>    WIN32 _WIN32 __CYGWIN__
>
>    $ gcc -o test -mno-cygwin test.c
>    $ ./test
>    WIN32 _WIN32 __MINGW32__
>

Hmm, I thought _WIN32 was always defined when targeting Windows, and
that WIN32 was defined when windows.h was included (or usually in the
preprocessor flags when compiling GUI programs) - that's what MSVC
does anyway. MinGW seems to always define both _WIN32 and WIN32, but
as you've shown Cygwin doesn't define either until windows.h is
included.

So sorry for leading you onto the wrong path, a check for __CYGWIN__
seems to be necessary indeed.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]