Re: gcc 4.3 warnings




On Wed, 2008-08-06 at 22:34 -0700, Skunk Worx wrote:
Matthew Saltzman wrote:
On Tue, 2008-08-05 at 19:49 -0700, Skunk Worx wrote:
$ gcc foo.c
foo.c:1:16: warning: missing terminating " character

$ cat foo.c
#define DQUOTE "
main() {}

A few people at work have mentioned it seems unusual for a preprocessor
to complain about simple macros this way.

What do others think of this?

A macro definition has to consist of a sequence of tokens. A string
constant (sequence of characters enclosed in double quotes) is a token,
but the double quote by itself is not.

If you are trying to construct strings containing macro defs, look at
the stringize operator (#) and token merge operator (##)in the
preprocessor documentation.


Exactly. This code was written circa 1991 and the warnings came with the
change to Fedora 9.

The preprocessor is being used to generate html code documentation in
the build, including named anchors (#).

A further review of K&R, and other sources on the web, show the use of
the preprocessor for this kind of task is not recommended.

I imagine it would be some effort to integrate in legacy code, but if I
understand what you're trying to do, it sounds like Doxygen might do
what you want. There are other, similar systems out there as well.
They generally use formatted comments and a separate processor to
generate documentation in various formats.


Thanks,
John


--
Matthew Saltzman

Clemson University Math Sciences
mjs AT clemson DOT edu
http://www.math.clemson.edu/~mjs

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list



Relevant Pages

  • Wheres the beef?
    ... Is it possible to define a macro substitution in the C++ preprocessor so ... heavily invested in MFC, and certain capabilities (Class Wizard & Browser ... no longer usable under previous development systems. ...
    (microsoft.public.vsnet.ide)
  • Re: String comparison in preprocessor commands
    ... that won't work: The preprocessor can generate ... string literals, but it can't actually work with strings. ... and rely on the compiler to eliminate dead code: ... > position to change the macro definition. ...
    (comp.lang.c)
  • Re: tolower macro
    ... tolower is a macro defined like this. ... between a lower case character and it's uppercase equivalent. ... Does the preprocessor just ... replacing the character sequences given inside the macro as the names ...
    (comp.lang.c.moderated)
  • Re: gcc 4.3 warnings
    ... A few people at work have mentioned it seems unusual for a preprocessor ... A macro definition has to consist of a sequence of tokens. ... A string ...
    (Fedora)
  • Re: Mapping source instructions to machine instructions
    ... reality as well) operates in two separate phases. ... This isn't really much different from a C compiler and its preprocessor. ... m4 macro processor before feeding the output to the assembler proper. ... Anyway, in many, perhaps most, assemblers the macro processor is very ...
    (alt.lang.asm)