delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/01/15/00:33:31

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" <n_abing AT ns DOT roxas-online DOT net DOT ph>
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
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

At 12:52 PM 01/12/2001 +0200, you wrote:
>> Date: Fri, 12 Jan 2001 08:48:16 +0800
>> From: "Nimrod A. Abing" <n_abing AT ns DOT roxas-online DOT net DOT ph>
>> 
>> 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

- Raw text -


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