Re: Compile Error C1017 With sizeof()



"Alexander J. Oss" <alex@xxxxxxxxxxx> wrote in message
news:e7yRTX$cGHA.4312@xxxxxxxxxxxxxxxxxxxx
The preprocessor language includes "constant-expression" (according to
16.1.1 and 16.1.3), and 5.19 is what defines an integral
"constant-expression", and that definition includes sizeof().

...ugh, I just found the following quote at
http://msdn2.microsoft.com/en-us/library/ew2hz0yd.aspx:

The expression cannot use sizeof or a type-cast operator.

Why is this quote present here but not in the C++ standard (that I
could find)?

16.1/1 The expression that controls conditional inclusion shall be an
integral constant expression except that: it shall not contain a cast;
identifiers (including those lexically identical to keywords) are
interpreted as described below;136) ...

16.1/3 ... After all replacements due to macro expansion and the defined
unary operator have been performed, all remaining identifiers and
keywords, except for true and false, are replaced with the pp-number
0...

136) Because the controlling constant expression is evaluated during
translation phase 4, all identifiers either are or are not macro names -
there simply are no keywords, enumeration constants, and so on.



That is, as far as preprocessor is concerned, sizeof(int) is the same as
0(0) , which is obviously nonsense.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages

  • Re: Compile Error C1017 With sizeof()
    ... Why is this quote present here but not in the C++ standard (that I ... identifiers are ... After all replacements due to macro expansion and the defined ... keywords, except for true and false, are replaced with the pp-number 0... ...
    (microsoft.public.vc.language)
  • Re: Windows Explorer - File Property Sheet
    ... To see the Keywords you have to open a file's Properties. ... Not all file formats will support these additional column settings. ... MS-MVP Windows Shell/User ...
    (microsoft.public.windowsxp.general)
  • Re: "as" keyword woes
    ... In some languages ... "ELSE" could be identifiers, so you could have code like: ... I just take you to have meant, then, +1 on excluding keywords from ...
    (comp.lang.python)
  • Re: The Dwarf Beneath the Bed
    ... affect of your keywords for you, the allusions were mere drijbble>>> in a pot of Pablum. ... his claim that I owe Rob something for using his Psycho Dwarf ... Got a quote? ...
    (rec.arts.poems)
  • Re: The Dwarf Beneath the Bed
    ... affect of your keywords for you, the allusions were mere drijbble>>> in a pot of Pablum. ... Got a quote? ...
    (rec.arts.poems)

Loading