[splint-discuss] Parse error with @ from the IAR compiler

Michael Wojcik Michael.Wojcik at MicroFocus.com
Wed Apr 30 06:33:33 PDT 2008


> From: splint-discuss-bounces at cs.virginia.edu 
> [mailto:splint-discuss-bounces at cs.virginia.edu] On Behalf Of 
> Richard A. O'Keefe
> Sent: Wednesday, 30 April, 2008 06:18
> >
> > -D@="; //"
> 
> This makes no sense:  C syntax only allows you to #define 
> identifiers, and @ is not in the C alphabet.

Actually, I believe an implementation is allowed, though not required,
to support this.

ISO 9899-1990 ("C90") 5.2.1 allows the source character set to include
additional characters ("at least the following members").

It ends with the note:

"If any other characters are encountered in a source file (except in a
character constant, a stirng literal, a header name, a comment, or a
preprocessing token that is never converted to a token), the behavior is
undefined."

That might seem to contradict the implicit permission to add characters
to the source character set. However, in this particular case - defining
"@" as the name of an object-style macro - "@" will be a preprocessing
token that is never converted to a token. See 5.1.1.2 #3 - #7; macro
expansion happens long before pp-tokens are converted to tokens.

ISO 9899-1999 plus corregenda ("C99") clarifies this situation, noting
that both the source character set and the execution character set can
be extended with additional locale-specific members. It even allows
multibyte characters in the source character set, including multibyte
character sequences in identifiers (5.2.1.2).
 
In this case, of course, the implementation is Splint. And Splint
doesn't add "@" to the source character set, so the discussion is moot.

Your solution is definitely a better one. (I'm not sure I'd use "at" as
a function-style macro name, but that's a matter of style.) Splint is a
source analyzer for C, not for languages which look like C but have
special syntactic extensions. Developers who want to use Splint should
write C, and let their implementation translate it into not-quite-C as
necessary, using macros.

-- 
Michael Wojcik
Principal Software Systems Developer, Micro Focus



More information about the splint-discuss mailing list