LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 03-30-2009, 01:22 PM   #1
hedpe
Member
 
Registered: Jan 2005
Location: Boston, MA
Distribution: Debian
Posts: 380

Rep: Reputation: 30
declaration error trying to use flex with c++


Hi all,

I am trying to build an architecture simulator (http://cva.stanford.edu/books/ppin/#sim) that uses flex with bison to generate some code. I'm not extremely familiar with either tool. It first uses flex to generate configlex.cpp from config.l:
Code:
flex -Pconfig -oconfiglex.cpp config.l
Here is config.l and configlex.cpp, respectively:
http://pastebin.com/f746a6b77
http://pastebin.com/f598c894e

Line 18 in config.l has:
Code:
unsigned int configlineno = 1;
After flex runs, configlex.cpp generates:
Code:
extern int configlineno; // line 361
int configlineno = 1; // line 363unsigned int configlineno = 1; // line 493
This obviously creates a problem when it tries to build:
Code:
config.l:18: error: conflicting declaration ‘unsigned int configlineno’
configlex.cpp:363: error: ‘configlineno’ has a previous declaration as ‘int configlineno’
Why does it generate both an int and an unsigned int? I would appreciate any feedback.

Thanks!
George

Last edited by hedpe; 03-30-2009 at 01:23 PM.
 
Old 03-30-2009, 07:15 PM   #2
hedpe
Member
 
Registered: Jan 2005
Location: Boston, MA
Distribution: Debian
Posts: 380

Original Poster
Rep: Reputation: 30
fixed, apparently <prefix>lineno is an internal flex variable name

Last edited by hedpe; 03-30-2009 at 07:16 PM.
 
  


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
ERROR previos declaration raixun Programming 2 08-28-2008 04:40 AM
flex/bison -> parse error but why? vargadanis Programming 3 08-03-2008 07:44 PM
Using Flex and Bison to parse the variable declaration section in Pascal unreal07 Programming 1 03-10-2007 08:25 PM
Implicit Declaration Compiler Error Mistro116@yahoo.com Programming 1 12-11-2005 04:24 AM
ahhh wine and flex error! help :( xpcandrew Linux - Newbie 3 02-01-2005 02:05 AM

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

All times are GMT -5. The time now is 10:08 PM.

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