Mail Archives: cygwin/2009/03/18/07:42:00
Corinna Vinschen wrote:
> On Mar 17 21:15, Charles Wilson wrote:
>>
>> +#if defined(_WIN32) && !defined(__CYGWIN__)
> The !defined(__CYGWIN__) is not necessary because gcc for Cygwin
> doesn't define _WIN32.
gcc does not define it. But the w32api headers DO.
/usr/include/w32api/windef.h:
#ifndef WIN32
#define WIN32
#endif
#ifndef _WIN32
#define _WIN32
#endif
So, if you #include windows.h, you'll have _WIN32 defined. If your code
needs to do different stuff on "real" win32 and cygwin, then you need
this kind of #if _WIN32 && !CYGWIN magic. libarchive fits this category,
because even the cygwin port uses some win32 calls (there's special code
to check if you have "root"-ish permissions, which looks up SIDs and
checks your group memberships...)
> extern int _fmode;
> _fmode = O_BINARY;
I didn't know you could access it directly, outside of cygwin1.dll.
> _fmode is defined in crt0.o so you can simply access it if you like.
> But anyway, using binmode.o is much more elegant, IMHO. I don't see
> what speaks against using it.
Well, now that I see libbinmode.a, nothing.
But using /usr/lib/binmode.o in your build rules is non-portable, and
breaks cross-compiles (my linux box doesn't have that file, and even if
it did it wouldn't be cygwin's). gcc doesn't search the -L path for
.o's, so you can't just specify 'binmode.o', you have to give the full
path. So I was stuck with a patch that would not be acceptable
upstream, to explicitly add "/usr/lib/binmode.o" to the LDADD variable
with an AM_CONDITIONAL on $host=cygwin. Ugly.
At least now, I see that I can use an AM_CONDITIONAL to add -lbinmode to
LDADD, which is much cleaner and actually works on cross builds.
--
Chuck
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -