gcc specs

Erik Postma epostma at nl.tue.win
Mon Mar 15 01:12:55 PST 2004

On Sun, 14 Mar 2004 15:29:03 -0500, Robert Connolly <cendres at videotron.ca>
> I have a problem cause I dont know C very well. I'm close to having a
> patch that will add -fstack-protector-all to any machine type, OS, and
> gcc version. I have a problem because I can't copy a macro and undef the
> original.
> static char CC1_PREPEND_SPEC[] = CC1_SPEC;
> #undef CC1_SPEC
> This doesn't work but some of you might see what I'm trying to do. Any 
> suggestions?

I guess there may be more reasons that it doesn't work, but one of those 
is that it now expands to a string pointer followed by an in-place
""-string. The C compiler does do concatenation of strings, but only of
""-strings, it doesn't combine the two.

One idea to solve this problem would be this:

static char cc1_spec_string[] = CC1_SPEC STD_SSP_EXCLUDE(CC1_SSP)
#undef CC1_SPEC
#define CC1_SPEC (cc1_spec_string)

Now if the code somewhere relies on it being a macro and thus effectively
a ""-string, it will go wrong. E.g. if it says somewhere

char instance1 [] = CC1_SPEC;
/* do something to instance1 */
char instance2 [] = CC1_SPEC;
/* now expect instance2 to be untouched */

that would work with a macro, but not like this. OTOH, straightforward use
would be no problem.

Erik Postma (Email: reverse the order of nl, tue and win.)
GPG key: http://www.win.tue.nl/~epostma/gpg.key

More information about the hlfs-dev mailing list