Message-Id: <3.0.1.32.20010115131743.006b86ec@wingate> X-Sender: n_abing#ns DOT roxas-online DOT net DOT ph AT wingate X-Mailer: Windows Eudora Pro Version 3.0.1 (32) Date: Mon, 15 Jan 2001 13:17:43 +0800 To: djgpp AT delorie DOT com From: "Nimrod A. Abing" Subject: Re: Calling C++ functions from C (or using Bison with C++) Cc: eliz AT is DOT elta DOT co DOT il In-Reply-To: <9743-Fri12Jan2001125255+0200-eliz@is.elta.co.il> References: <3 DOT 0 DOT 1 DOT 32 DOT 20010112084816 DOT 006bc314 AT wingate> <3 DOT 0 DOT 1 DOT 32 DOT 20010112084816 DOT 006bc314 AT wingate> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk At 12:52 PM 01/12/2001 +0200, you wrote: >> Date: Fri, 12 Jan 2001 08:48:16 +0800 >> From: "Nimrod A. Abing" >> >> Now, I've tried doing it using pointers to functions. It works, but >> (heheheh) is there a better way to do this? > >Indeed there is: you need to tell the C++ compiler that the parser is >a C function, not a C++ function, like this: > > extern "C" int my_parser (void); Thanks Eli, but I wanted to do it (strange as it may seem) the other way around: Call C++ functions from _within_a_Bison_rule_. A Bison grammar file gets turned into a C program by the Bison program. Tim Van Holder's suggestion of using ``extern'' language declarations will not (and does not) compile because C doesn't recognize the extern "C" construct. Although I will try out some of his suggestions. It seems that there are two ways to get this done. One is to use casts here and there, as Tim suggests. On the other extreme, a complete rewrite and rethinking of the program. The second alternative should be more viable in the long run. However, since I don't have the time to do a complete rewrite I might as well stick to using casts (*ugh*). nimrod_a_abing -------------- +========================================+ | Home page: www.geocities.com/n_abing | +========================================+ ICQ: 54665893