Author Topic: How to change compiler for Auto-generated files like .cc .y .l  (Read 3634 times)

Offline eckard_klotz

  • Almost regular
  • **
  • Posts: 194
How to change compiler for Auto-generated files like .cc .y .l
« on: December 12, 2014, 12:29:33 pm »
Hello Everybody.

Currently I try to compile the sources of the following project : http://www.mcternan.me.uk/mscgen/

Since this project is using the bison-tool to generate grammar-files I already installed bison and flex as well as the libintl-dlls. Thus the grammar-files will be generated as desired.

Since the project it self is written in c and not in c++ they will be compiled with the c-compiler (MinGw tdm-gcc-4.8.1-3). But for the auto generated files Code::Blocks forces to use the c++ compiler and the adjustment that normally allows to change this is not accessible. Even all files will be compiled the linker is not able to find all symbols since the c++ compiler is using name-mangling and the c-compiler not.

I think the long-lasting strategy should be to transfer the project to cpp but for the beginning I wish to keep it as provided since a lot of changes have to be done to make the sources acceptable for the c++ compiler (own boolean-type, forbidden pointer-conversion, ...) . Thus my problem is to ensure that all files will be compiled with the c-compiler.

How can I adjust that attachments like .cc .y .l  will be compiled with CC and not with CPP ?

Best regards,
                      Eckard.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to change compiler for Auto-generated files like .cc .y .l
« Reply #1 on: December 12, 2014, 01:15:03 pm »
One idea would be to create a special compiler for this kind of project.
Copy the compiler you use now and use the c-compiler for c++-files also, and use this compiler for the project/targets.
Other way would be to change the file-ending of the bison-created files in the advanced settings of the compiler.
It might also be possible to make bison create header-files that prevents name mangling with an extern "C" statement.

Offline eckard_klotz

  • Almost regular
  • **
  • Posts: 194
Re: How to change compiler for Auto-generated files like .cc .y .l
« Reply #2 on: December 13, 2014, 03:08:10 pm »
Hello Jens.

Thanks for your quick response and please excuse my late one.

Quote
Other way would be to change the file-ending of the bison-created files in the advanced settings of the compiler.
In the case you talk about an adjustment in Code::Blocks, where do I find the advanced settings of the compiler ?

Best regards,
                     Eckard.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: How to change compiler for Auto-generated files like .cc .y .l
« Reply #3 on: December 13, 2014, 03:14:55 pm »
In the case you talk about an adjustment in Code::Blocks, where do I find the advanced settings of the compiler ?
Menu->Settings->Compiler->Other settings page. You will see it is a right bottom button named "advanced options"
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline eckard_klotz

  • Almost regular
  • **
  • Posts: 194
Re: How to change compiler for Auto-generated files like .cc .y .l
« Reply #4 on: December 13, 2014, 04:31:17 pm »
Hello Ollydbg.

Thanks for the hint. After cleaning my glasses I have found. But I think it will take a while to understand how to force compiling a file with the ending cc with the MinGW c compiler instead with the c++ compiler.

How ever I think I have now enough possibilities to try out now. Thus  Jens and Ollydbg, thank you very much.

Best regards,
                      Eckard.