Topic: header-name tokenization


Author: "Gennaro Prota" <gennaro_prota@my-deja.com>
Date: Tue, 24 Jul 2001 19:20:39 GMT
Raw View

[
TO THE MODERATOR: this is a question I posted some days ago without any
answer; maybe it was not so interesting to inspire someone to reply or,
maybe, my wording was a bit obscure. Can I ask it again? :-)
]

Hi everybody,
 after reading the clause 2.8 of the standard I have some doubts about
header-name prep-tokens,  for instance:
 if I write

    #define HEADER_NAME "myfiles/file.h"

how is "myfiles/file.h" parsed? As a single header-name prep-token, as a
single string-literal prep-token, or as a sequence of tokens?

I ask this after a look to STLport's source code, which in order to locate
some headers coming with specific compilers uses macros like the following:

    #  define _STLP_NATIVE_HEADER(x) <../crt/##x>

which are then used in #include directives, e.g:

    # include _STLP_NATIVE_HEADER(string)

I'm very confused about this tecnique! For the x to be identified as a
macro-parameter, isn't it needed that it is parsed as a separate token
(identifier)? So, I see two possibilities: or <../crt/##x> gives a single
header-name/string-literal (which one?) token, so we end up having
_STLP_NATIVE_HEADER's replacement list as if it didn't contain the parameter
name, or <../crt/##x> is parsed as:

 token(<) token(.) token(.) token(/) token (crt) token (/) token(##)
token(x) token (>)

but in that case ## is illegal because, due to the slash, it can't give a
SINGLE valid token.

Am I right? Thanks everybody for the help! :-)



Genny.



---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]