Mail Archives: djgpp/1999/07/16/02:44:37
> > Is there any way of inserting a marker into C code that is compiled but
> > not run?  It would be really helpful if I could put comments (of a sort)
> > right into the binary.
> 
> If you don't care exactly where in the binary it ends up, you could just
> do
> 
> static char my_comment[] = "Hello, world";
> 
> The compiler may warn you about an unused static variable, though.
It would need to be found, so if I did this I would have to put some
unique token at the beginning that coudl not turn up anywhere else. 
That's not the best idea...
> > I imagine that maybe I could do it with inline assembly that jumps over
> > a text string, but would the optimizer throw that out?
> 
> If you want to have it in just the right place, then yes, you could do
> that.  Using `volatile' will prevent the optimizer from moving or
> removing it (in fact I think it might not even be necessary for asms
> with no output).
I heard to use asm volatile from someone else, too.  Does this work in C
as well as in C++?  I read that the "asm" keyword is new for C++. 
However, I see inline assembly in Allegro.  Hmm.  Is this a deviation
from the standard?
> asm volatile("jmp 0f; .string \"Hello, world\"; 0:");
Is that really jmp 0f?
                    ^
  ___  _   _ ____  _   _
 / _ \| \ | |  _ \\ \_/ / .--------[ ICQ#: 35256413 ]--------.
| |_| |  \| | | | |\   /  | 01001000011001010110110001101100 |
|  _  | \ \ | | | | | |   | 01101111001011000010000001110111 |
| | | | |\  | |_| | | |   | 01101111011100100110110001100100 |
|_| |_|_| \_|____/  |_|   `--[ mailto:andygoth AT vetec DOT com ]---'
<http://zap.to/andygoth/>           <http://andygoth.cjb.net/>
- Raw text -