On Thu, 12 Aug 2004 20:40:05 +0800, " Bern" <x@x.com> wrote in
comp.lang.c++:
[color=blue]
> The following is C code:[/color]
No it's not, not legal or correct C code, nor is it legal or correct
C++ code.
[color=blue]
> typedef struct __Haha Haha, *PHaha;[/color]
All identifiers beginning with two underscores, or with an underscore
followed by an uppercase letter, are reserved for the implementation
in both C and C++. It is not legal for you to define such symbols in
your program.
[color=blue]
> struct __Haha {
>
> int i;
>
> };
>
> void main(){[/color]
"void main()" is not legal in either C or C++. Both languages require
that main() be defined with a return type of int.
[color=blue]
> Haha haha;
>
> haha.i = 123;
>
> PHaha phaha = & haha; // <<<<< error line
>
> phaha->i = 234;
>
> }
>
> ---------------------------------------------
>
>
>
> i compiled the code above in C using MS compiler and it
>
> generates an error in the line indicated.
> The error is "illegal use of this type as an expression".
> Yet when i compiled it as C++ code, everything is alright.
> So whats the problem?[/color]
The problem is that you are writing code that is invalid in both
languages, and using a compiler that does not conform to either
language standard.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html