This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: impure_ptr/Mingw and Cygwin


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@Salira.com <mailto:Andrew%20DeFaria%20%3CADeFaria@Salira.com%3E>
Web: http://www.salira.com

Instant Messaging
AIM:
defaria
MSN:
Andrew@DeFaria.com
Yahoo:
andrew_defaria
ICQ #:
23552673


Andrew DeFaria <http://DeFaria.com>
Clearcase Administrator
Email: Andrew@DeFaria.com <mailto:Andrew@DeFaria.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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]