Do comments get compiled into the exe file? Doesn't make sense that they are if they do since an exe file doesn't need them anyway.
So are they automatically removed when the c-source code is compiled?
Do comments get compiled into the exe file? Doesn't make sense that they are if they do since an exe file doesn't need them anyway.
So are they automatically removed when the c-source code is compiled?
>Do comments get compiled into the exe file
No.
>So are they automatically removed when the c-source code is compiled?
Yes.
A whole bunch of other stuff gets removed as well.
So when someone asks you "can I see the source given the .exe", you know what the answer is.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
They're not removed so much as just ignored and skipped when the compiler is going through the source.
Depends a bit on how you look at it, really. A classic C-compiler consists of four stages:
* cpp - preprocessor, deals with all #include, #define, #if and so, and also normally removes ALL comments.
* cc1 - generates assembler code from the now preprocessed C-code.
* as - assembler to object
* ld - linker/loader - puts all object files together, reads libraries etc.
Whilst most compilers don't consist of different parts in this manner any longer, they still follow pretty much this principle - first go through and do all the #include, #define, #if and remove comments, then compile the code after this stage. However, there are references to the original source and where in the source the code actually came from, so that a source level debugger can show you the original source-code. But that is in the form of line number and source-filename. As far as I know, no compiler stores the actual source code within the debug information.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.