delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/11/25/19:53:17

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <3DE2C59A.9030103@Salira.com>
Date: Mon, 25 Nov 2002 16:51:38 -0800
From: Andrew DeFaria <ADeFaria AT Salira DOT com>
Organization: Salira Optical Networks
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
X-Accept-Language: en-us, en, ru, zh
MIME-Version: 1.0
To: "Peter A. Castro" <doctor AT fruitbat DOT org>
CC: cygwin AT cygwin DOT com
Subject: Re: impure_ptr/Mingw and Cygwin
References: <Pine DOT LNX DOT 4 DOT 21 DOT 0211251615350 DOT 7231-100000 AT gremlin DOT fruitbat DOT org>
X-OriginalArrivalTime: 26 Nov 2002 00:52:56.0890 (UTC) FILETIME=[28DF31A0:01C294E6]

Peter A. Castro wrote:

>On Mon, 25 Nov 2002, Andrew DeFaria wrote:
>
>>Peter A. Castro wrote:
>>    
>>
>>>On Sun, 24 Nov 2002, Andrew DeFaria wrote:
>>>      
>>>
>>>>Peter A. Castro wrote:
>>>>
>>>>        
>>>>
>>>>>What you show below is only linking. I believe you need to 
>>>>>re-compile all of your source with -mno-cygwin -mwindows as well to 
>>>>>make the _impure_ptr references go away.
>>>>>          
>>>>>
>>>>But I did re-compile all my sources with -mno-cygwin -mwindows! Still 
>>>> have the error.
>>>>        
>>>>
>>>Suggest you run nm against all your objects and libraries and find which
>>>has the _impure_ptr references, then recompile just those.
>>>      
>>>
>>But I did recompile everything already! The _impure_ptr keeps getting 
>>generated:
>>
>>$ nm mksf.o | grep impure
>>         U __impure_ptr
>>$ rm mksf.o
>>$ make mksf.o
>>/bin/gcc -c -g -mno-cygwin -mwindows -I. -I../../include -I/usr/include 
>>-DCYGWIN mksf.c
>>$ nm mksf.o | grep impure
>>         U __impure_ptr
>>$
>>    
>>
>
>You're getting stdio.h from /usr/include, that's why.
>
>  
>
>>As you can see the _impure_ptr reference gets regenerated. But wait! 
>>There's more!
>>
>>I can cause these _impure_ptr even with the little foo.c merely by 
>>including -I/usr/include on the command line. Why am I referencing 
>>/usr/include? Because in my larger application I need it for getopt.h. 
>>The mere inclusion of -I/usr/include causes_impure_ptr's to be emitted. 
>>So the question now is: How do I satisfy my need for getopt and still 
>>produce objects without _impure_ptr's?
>>    
>>
>
>libiberty.a in /usr/lib/mingw has getopt(), so link with -liberty
>
>  
>
>>Ah ha!
>>
>>$ grep impure /usr/include/*.h
>>/usr/include/stdio.h:#define    stdin   (_impure_ptr->_stdin)
>>/usr/include/stdio.h:#define    stdout  (_impure_ptr->_stdout)
>>/usr/include/stdio.h:#define    stderr  (_impure_ptr->_stderr)
>>
>>Hmmm... Changed options to:
>>
>>/bin/gcc -c -g -mno-cygwin -I. -I../../include -I/usr/include/mingw 
>>-I/usr/include -DCYGWIN mksf.c
>>cc1: warning: changing search order for system directory 
>>"/usr/include/mingw"
>>cc1: warning:   as it has already been specified as a non-system directory
>>
>>This works but why am I getting this warning?
>>    
>>
>
>Because -mno-cygwin specifies /usr/include/mingw as a system dir and
>you're specifying it again on the command line with -I, which makes it a
>User dir too.  gcc is a bit puzzled about why you're doing that. 
>
>If you add the "-v" flag to you compile flags, gcc will dump the list of
>directories it searches for include files.  In this case it would be:
>
> ../../include
> /usr/include/mingw
> /usr/include
> /usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-5/include
> /usr/include/mingw
> /usr/include/w32api
>     
>  
>
If this were really so then why, if I don't specify -I/usr/include I get 
getopt.h not found?!? I should be found in /usr/include/getopt.h no?

In any event, after reading up on this problem in the MingW mailing list 
I find that I am not the only one with this problem. Seems that -liberty 
does indeed have the code for getopt but there is no mingw header file 
that defines the interface. My solution ended up being define the getopt 
API by hand and put it in my own mksf.h header file. Ugly but it works.

Thanks for working this out with me.
-- 

Salira <http://www.salira.com>
Ethernet Simple, Fiber Fast

5451 Patrick Henry Drive
Santa Clara, CA 95054
Phone: (408)-845-5321
Fax: (408)-845-5205
Email: ADeFaria AT Salira DOT com 
<mailto:Andrew%20DeFaria%20%3CADeFaria AT Salira DOT com%3E>
Web: http://www.salira.com

Instant Messaging
AIM:
defaria
MSN:
Andrew AT DeFaria DOT com
Yahoo:
andrew_defaria
ICQ #:
23552673


Andrew DeFaria <http://DeFaria.com>
Clearcase Administrator
Email: Andrew AT DeFaria DOT com <mailto:Andrew AT DeFaria DOT com>
Web: http://DeFaria.com







--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019