codealot_sir wrote:
> So, I know that the compiler totally ignores comments, but just to be
> sure, do all of the
> following get translated into machine language?
> - compiler directives

Compiler directives (mostly) don't translate into machine language, but
they can affect how other things get translated.  E.g., a compiler
directive may change how alignment is done on items in a struct, or when
the result of a given computation is "materialized" (stored into
memory).

However, the meaning of a compiler directive (assuming you mean a
pragma) is entirely up to the compiler's implementer, so it is legal to
have compiler directives that generate machine language.

If by "compiler directive" you mean a preprocessor directive (#if,
#else, #define, etc.), then these can affect what gets generated but
don't directly translate to machine language.

> - using namespace statement

Doesn't translate to machine language, but again can affect how other
statements get translated to machine language.

> - variable declarations

See above.  In addition, a variable declaration that contains an
initializer *may* be translated into machine language.  Or it may be
optimized away, depending on how the variable's value(s) is used.

> - executable statements

Well, I would hope so.  But again, the compiler is free to generate any
code it wants (including none at all), as long as the language semantics
are obeyed.

For example:

int main(int argc, char** argv)
{
      int a;
      int b;

      a = 2;
      b = a*3 + 4;
      return 0;
}

May generate only the function preamble and the return statement,
because a and b are "dead variables" -- their values never affect
anything visible outside the function.  In fact, the above could
generate as little as
(in x86 assembler)

mov eax,0
ret

or perhaps

sub eax,eax
ret


To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>.


Yahoo! Groups Sponsor
ADVERTISEMENT
click here
Web Bug from http://us.adserver.yahoo.com/l?M=298184.5639630.6699735.3001176/D=groups/S=:HM/A=2434971/rand=867912725


Yahoo! Groups Links

Reply via email to