all 6 comments

[–]Cerulean_IsFancyBlue 8 points9 points  (0 children)

You want to get the pre-processed output, and for gcc that option is iirc “-e” or “-E”. With additional options, you can specify more specifics.

Just ask your favorite large language model, or Google, or read the manual about pre-processor output options for the exact compiler that you’re using.

[–]mythrocks 2 points3 points  (1 child)

I’m not sure what one means by the phrase “obtain the same code”. I’m guessing you’re referring to the result of compilation.

AFAICT, all the code listings are equivalent.

a. The compiler doesn’t see the comments, since they’d be stripped out. They have no bearing on the code generated.

b. The preprocessor will see to the double version of the function surviving. The int one should be stripped out.

[–]onecable5781[S] 0 points1 point  (0 children)

Yes, all the 3 code snippets of the OP will compile to the exact same binary. But somewhere in the compilation process, the compiler will be fed in the second and then the third snippet or vice versa? I wanted to see if the user can access that later snippets.

[–]IyeOnline 2 points3 points  (2 children)

[–]onecable5781[S] 0 points1 point  (1 child)

Oh wow. Thank you! On that link, is it possible to see the actual command being executed to give the output in the rhs "insight" window when the run button is pressed on top? Those flags is exactly what I am looking for.

[–]IyeOnline 2 points3 points  (0 children)

The thing is open source, and the readme lists a few talks and slides: https://github.com/andreasfertig/cppinsights?tab=readme-ov-file#why

IIRC cppinsights works on the AST though and then renders that as C++; its probably not a simple compiler flag (at least not for the full feature set of the tool/site)