Message-Id: <3.0.1.32.20010112084816.006bc314@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: Fri, 12 Jan 2001 08:48:16 +0800 To: djgpp AT delorie DOT com From: "Nimrod A. Abing" Subject: Calling C++ functions from C (or using Bison with C++) Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Reply-To: djgpp AT delorie DOT com Hello. I've got an interesting problem. I am writing a program using Bison, Flex, and C++. The problem is this, I have done the parser and lexer using Bison and Flex respectively. The guts of the program I intend to write using C++. The lexer part is okay, because Flex can generate a C++ scanner (albeit an experimental one). The problem is with the Bison generated parser. I intended to call C++ functions from within the parser rule-actions until I realized that this would be a problem because the parser is in C. Now, I've tried doing it using pointers to functions. It works, but (heheheh) is there a better way to do this? [ file test.cc ] #include void test() { cout << "Haha it works!!!" << endl; } void (*test_addr)() = test; [ --end--] [ file main.c ] #include extern void (*test_addr)(); int main(void) { (*test_addr)(); exit(0); } [ --end-- ] Help please... nimrod_a_abing -------------- +========================================+ | Home page: www.geocities.com/n_abing | +========================================+ ICQ: 54665893