C, C++, Flex and Bison


I have code converter (converts from Pascal to C) which was created with Bison and Flex. The bison code is written in C.
And now I'm trying to add GUI to this project, but I have no experience with Qt. It is possible to integrate my code (in C) with simple GUI created in C++? I have no idea how to start.

I would appreciate any advice.

(Sorry for my english)



  • C++ GUI code can call arbitrary functions written in C. Depending on your tool you may have to edit the C++ manually or you may have some point and click interface, however this ability is a very basic feature of all GUIs.
    The C code needs to be declared extern "C" to link correctly if it is in its own source file.
    Generally it is a good idea to separate GUI code from the "business logic" or core fucntionality of the program.
  • Thanks.

    But actually,
    where should I put this "extern" block?

    These are my files:
    [italic]grammar.l, grammar.y[/italic] (flex and bison files, C code)
    [italic]lex.yy.c[/italic] (generated with flex)
    [italic]grammar.tab.c[/italic], grammar.tab.h (generated with bison)
    [italic]parserGui.cpp[/italic] (created with KDevelop)

    There is a main() in [italic]grammar.tab.c[/italic] (where the [italic]yyparse()[/italic] is called) and I suppose, I should get rid of it and call [italic]yyparse()[/italic] in main() in [italic]parserGui.cpp[/italic]...

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!