one more thing

Brian Dessent brian@dessent.net
Fri Sep 21 03:38:00 GMT 2007


patrickinminneapolis wrote:

> example_wrap.c includes <cstudio>, but gcc can't find it, can you tell me
> how to tell gcc to look in c:\Program Files\Microsoft Visual Studio
> 8\VC\include\ for it?

Setting aside for a moment the fact that you're trying to do something
totally wrong and broken, the reason the compiler cannot find <cstdio>
is that you named the file with a .c extension and are compiling it with
gcc.  If you want to use C++, you need to compile with g++.  If you name
your files with C++ extensions (.cc, .cpp, .C) then gcc will be able to
detect that you want C++ mode and that will also work, however you will
likely get linking errors if you try to link with gcc when you should be
using g++.  In other words: always use g++ when compiling or linking C++
code.

With that out of the way, you're trying to do something nutso by telling
gcc to use MSVC's C++ headers.  There's no way that's going to work. 
Implementations of C++ standard libraries and headers are very tightly
bound to internal details of the compiler, so you have to use gcc's
<cstdio> if you want to use C++ -- and you shouldn't ever need any
special flags to get the compiler's own C++ headers, providing that you
invoke the right driver.  And even if C++ headers were not tied to the
compiler implementation, g++ and MSVC++ implement different ABIs so
trying to link C++ objects/libraries across vendors will fail.

The only exchange of headers that typically works is when you are
dealing with pure C only, and when the headers are designed to be
generic and portable.  Otherwise, don't expect to be able to point gcc
at MSVC internal headers and have anything but great failure.

Brian

--
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/



More information about the Cygwin mailing list