X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: sourceware.org Message-ID: <49C0EC08.8020907@cwilson.fastmail.fm> Date: Wed, 18 Mar 2009 08:41:44 -0400 From: Charles Wilson User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.19) Gecko/20081209 Thunderbird/2.0.0.19 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: _set_fmode? References: <49C04B2D DOT 2090703 AT cwilson DOT fastmail DOT fm> <20090318094323 DOT GA12824 AT calimero DOT vinschen DOT de> In-Reply-To: <20090318094323.GA12824@calimero.vinschen.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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/