Mail Archives: djgpp/1999/07/16/01:32:57
Andy Goth wrote:
>
> 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.
> 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).
asm volatile("jmp 0f; .string \"Hello, world\"; 0:");
--
Nate Eldredge
nate AT cartsys DOT com
- Raw text -