delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/18/00:57:17.1

Sender: nate AT cartsys DOT com
Message-ID: <37915EED.5D68DAC@cartsys.com>
Date: Sat, 17 Jul 1999 21:58:21 -0700
From: Nate Eldredge <nate AT cartsys DOT com>
X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.10 i586)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: Marker
References: <378E8DD5 DOT 68B571A AT vetec DOT com> <7mnnns$39l$1 AT news DOT luth DOT se> <37914616 DOT 11FEAA6C AT vetec DOT com>
Reply-To: djgpp AT delorie DOT com

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.
> > :
> > : I imagine that maybe I could do it with inline assembly that jumps over
> > : a text string, but would the optimizer throw that out?
> >
> > Hmm. Will the compiler remove 'const char s[] = "My string\n";'?
> >
> > If it does try 'struct { char s[], void *p } my_var = { "My string\n",
> > &my_var };' wihch I haven't tested but should work. The trick is to
> > make sure you reference the string somewhere in the code.
> 
> What does the void* p part do (besides add four extra unused bytes)?

The structure needs to be referenced.  If it has a pointer in it, it can
reference itself.  Neat trick, that.
-- 

Nate Eldredge
nate AT cartsys DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019