0

I would like to see my esp-idf code after preprocessing (see which code inside of #ifdef will be compiled).

I tried adding "add_compile_optins(-E)" in my main CMake file, but the build failes :( Anyway I looked in the build dir, and saw .c.obj files (I expected to see .c files).

Is there another way to run only preprocessor? or that ESP-IDF does not support it?

Thanksss

10
  • Related: Can gcc output C code after preprocessing? Commented Oct 8, 2024 at 22:53
  • @WeatherVane not related as he does not want to use -E. Commented Oct 8, 2024 at 23:04
  • @0___________ it is related, because there is a lot of discussion of the topic, and one answer there is about -save-temps. Plainly this OP would like to use -E because they tried it. Commented Oct 8, 2024 at 23:18
  • Welcome to SO. Did you try to look into the .c.obj files? Depending on the tool chain, the output name might still be the same if you add -E option but the content changes. That is because the makefile specifies the name and it doesn't know that you don't compile but only preprocess. Then, of course, building fails because the linker will not be happy with what it gets. Commented Oct 9, 2024 at 6:34
  • The .c.obj files contain other things than the preprocessed code. I would like to see only my code - after preprocessor. Also I want to tell the compiler to stop after preprocessing (don't run the compiler and the linker...) Commented Oct 9, 2024 at 6:55

1 Answer 1

0

You can use -save-temps option. It should keep .i files (preprocessed files) in the build directory

Sign up to request clarification or add additional context in comments.

4 Comments

When I add "-save-temps" it won't compile (without this flag it does), and the .c.obj files are not created- The error is on "heap_caps_init.c".
@bakarbakar "does not compile" without providing complete and exact error message is not a useful information. As it applies to all files, the file name is way less useful than the error message.
The point is that the code can be compiled, but with the flag it doesn't.
@bakarbakar the point is that your comment is 100% useless. Without your error messages no one can tell if you used some option wrong or where the problem is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.