Re: Compile Error C1017 With sizeof()
- From: "Alex Blekhman" <tkfx.N05P4M@xxxxxxxxx>
- Date: Wed, 10 May 2006 14:29:20 +0300
Alexander J. Oss wrote:
It should, since sizeof isn't part of the preprocessor
language. And you're
right, sizeof(char) is 1 by definition. In C and C++
terms, "char" and "byte" are synonymous, and they don't
necessarily imply 8 bits, though usually they do.
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)?
Because C++ Standard is terse document, which provides
shortest (most of the time) definitions of language
concepts. MSDN is broader and includes commentaries and
interpretations. Once it's in preprocessor section of the
Standard the assumption is that compiler stuff is excluded.
MSDN explicitly states this fact and enumerates limitations
for preprocessor constant expression.
`sizeof' is compile time operator, i.e. it's evaluated by
compiler. Preprocessor runs before compilation, hence
`sizeof' is unknown during this stage.
.
- References:
- Compile Error C1017 With sizeof()
- From: Alexander J. Oss
- Re: Compile Error C1017 With sizeof()
- From: Doug Harrison [MVP]
- Re: Compile Error C1017 With sizeof()
- From: Alexander J. Oss
- Compile Error C1017 With sizeof()
- Prev by Date: Re: StretchBlt issue
- Next by Date: Re: Compile Error C1017 With sizeof()
- Previous by thread: Re: Compile Error C1017 With sizeof()
- Next by thread: Re: Compile Error C1017 With sizeof()
- Index(es):
Relevant Pages
|