delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/09/20/23:39:07

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Message-ID: <46F33CC5.DE2BCA23@dessent.net>
Date: Thu, 20 Sep 2007 20:38:45 -0700
From: Brian Dessent <brian AT dessent DOT net>
X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: one more thing
References: <12807222 DOT post AT talk DOT nabble DOT com> <46F30B1B DOT 4020007 AT sbcglobal DOT net> <12809503 DOT post AT talk DOT nabble DOT com>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/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

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/

- Raw text -


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