Author Topic: How to get the C generated code ?  (Read 1056 times)

Offline R1S8K

  • Multiple posting newcomer
  • *
  • Posts: 22
How to get the C generated code ?
« on: May 15, 2021, 12:25:32 pm »
Hi,

I'm using macros and having problem knowing how the code works. So one told me to use a flag that output the expanded generated code.

But I don't know how to use it in codeblocks.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13338
    • Travis build status
Re: How to get the C generated code ?
« Reply #1 on: May 15, 2021, 12:31:43 pm »
We don't have anything integrated for the task.
The easiest way is to do a build of the file, copy the command, modify it and run it in terminal.
If you do this often you can set up a tool for it.

Here are some hints about the flags needed: https://stackoverflow.com/questions/2224334/gcc-dump-preprocessor-defines
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline R1S8K

  • Multiple posting newcomer
  • *
  • Posts: 22
Re: How to get the C generated code ?
« Reply #2 on: May 15, 2021, 12:38:57 pm »
Sorry I forgot to mention that I use Windows 10.

Quote
The easiest way is to do a build of the file, copy the command, modify it and run it in terminal.

Can this  be done in Windows ?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13338
    • Travis build status
Re: How to get the C generated code ?
« Reply #3 on: May 15, 2021, 04:28:09 pm »
Yes. The principles and operation is the same on all OSes (mostly).
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2974
Re: How to get the C generated code ?
« Reply #4 on: May 17, 2021, 01:17:14 am »
Quick, easy and dirty you can add the -E flag in Project->Build options->Compiler settings->other compiler options

If you hit compile now, the generated object file (with the file ending .o in PROJECT_FOLDER/obj/BUILD_TARGET_NAME/SOURCE_FILE_NAME.o) will contain the preprocessed source. You can open it with any text editor you like. Linking will fail obviously. To compile the program again you have to remove the -E flag and make a rebuild: Build->Rebuild