Sharing memory among YACC, Lex, and C files

Posted by sczizzo on Stack Overflow See other posts from Stack Overflow or by sczizzo
Published on 2010-03-14T04:32:05Z Indexed on 2010/03/14 4:35 UTC
Read the original article Hit count: 484

Filed under:
|
|
|
|

I have a YACC (Bison) grammar, a Lex (Flex) tokenizer, and a C program among which I need to share a struct (or really any variable). Currently, I declare the actual object in the grammar file and extern it wherever I need it (which is to say, my C source file), usually using a pointer to manipulate it. I have a shared header (and implementation) file between the C file and the grammar file with functions useful for manipulating my data structure. This works, but it feels a little uncomfortable. Is there a better way to share memory between the grammar and program?

© Stack Overflow or respective owner

Related posts about yacc

Related posts about bison