LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-21-2011, 08:31 PM   #1
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Lex and YACC under C++ namespace


I'm making a shared library that contains a Lex/YACC parser. To keep the functions generated by Lex/YACC from conflicting with any names in a program linked to the library, I'd like to use namespaces.

The problem is that when I include namespace statements in the Lex input file, they come after some things and before others on the generated file, causing conflicts. Is I simply wrap the namespace statements around the generated file, it won't compile because the #include's are in the namespace.

What should I do?
 
Old 04-23-2011, 05:27 AM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by MTK358 View Post
I'm making a shared library that contains a Lex/YACC parser. To keep the functions generated by Lex/YACC from conflicting with any names in a program linked to the library, I'd like to use namespaces.

The problem is that when I include namespace statements in the Lex input file, they come after some things and before others on the generated file, causing conflicts. Is I simply wrap the namespace statements around the generated file, it won't compile because the #include's are in the namespace.

What should I do?
'gcc' allows you to obtain post-processed file, so all the include files are already included and all the '#ifdef's are resolved.

It should be much easier to add namespace to a single "flat" file.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Lex and YACC C++ namespace issue MTK358 Programming 4 04-14-2011 02:07 PM
lex and yacc aarsh Linux - Software 3 01-03-2011 08:58 AM
lex and yacc in RHEL4 birds Linux - Software 1 06-03-2009 02:56 AM
Lex and Yacc Information cmnorton Programming 4 11-04-2008 10:50 AM
LEX and YACC with C gr33ndata Programming 4 11-18-2007 05:12 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration