From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23601 invoked by alias); 23 Aug 2008 02:45:56 -0000 Received: (qmail 23593 invoked by uid 22791); 23 Aug 2008 02:45:55 -0000 X-Spam-Check-By: sourceware.org Received: from mail01.tanner.com (HELO mail01.tanner.com) (70.137.39.20) by sourceware.org (qpsmtpd/0.31) with SMTP; Sat, 23 Aug 2008 02:45:21 +0000 Received: (qmail 19022 invoked from network); 23 Aug 2008 02:45:19 -0000 Received: from unknown (HELO exchange01.tanner.com) (192.168.104.27) by mail01.tanner.com with SMTP; 23 Aug 2008 02:45:19 -0000 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: extern "C" From command line Date: Sat, 23 Aug 2008 02:46:00 -0000 Message-ID: In-reply-to: <48AF7666.E16B03F1@dessent.net> References: <200808191257.28899.zepm@gatech.edu> <48AE1E8A.12ADDE12@dessent.net> <48AF7666.E16B03F1@dessent.net> From: "Seyran Avanesyan" To: X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-08/txt/msg00251.txt.bz2 > Then you need C linkage, which means you have no choice but to enclose > the code in "extern C" (or compile it with a C compiler of course.) If > you really can't modify the source.cpp file then I still don't see why > you can't do something like: >=20 > extern "C" { > #include "source.cpp" > } Well, I can't do that because source.cpp allowed to contain #include-s. (Of course I can parse source.cpp and create modified_source.cpp. Just need to preprocess, then use yacc/lex or Spirit C-grammar parser...) I can also write my own, simplified grammar parser for source.cpp (since source.cpp is using C syntax). But I just tried to compile with "-x c++" with extern "C" in souce.cpp (experimentally added that manually), and when I tried to call it from MSVC app I've got a crash.