Mail Archives: djgpp/1995/06/02/13:48:17
Hi !!!
Yesterday I found something which was rather interesting for me.
I tried to change constant pointer and the constant value pointed by that
pointer.
Well... When I compiled with bcc everything was OK. Then, I thought
about gcc from DJGPP package and here's what I've found:
/* Program const.c */
int main()
{
int var1=13,var2 = 1;
const int* const swsi = &var1;
/*There are two errors compiling as C++ !!!*/
(int *) swsi = &var2; /*First*/
(int) *swsi = 2; /*Second*/
return 0;
}
While compiling as c-source:
gcc -O -Wall const.c -o const
I got two warnings but program compiled
just fine.
while compiling as C++ source:
gcc -O -Wall -x c++ const.c -o const
I got two errors (Yes errors ???) and
compilation was stoped.
Two above constructions are legal !!!. See for example:
--->"The C++ Programming Language" by Bjarne Stroustrup.<---
second edition.
I suppose it's rather strange when C++ compiler finds in a regular statement
an error. I think it is not as it should be.
Balzack.
Krzysztof Wa/sik
e-mail: kwasik AT lodz2 DOT p DOT lodz DOT pl
- Raw text -