Re: error C2099: initializer is not a constant problem



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Richard Tobin wrote:

In article
<a9330223-75f5-44a7-bcf5-ec3b16ecd628@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
merrittr <merrittr@xxxxxxxxx> wrote:

I have some C code I am compiling in VS 2005 using the C/C++ compiler
it seems to work except for the following error

FILE *fin = stdin;
FILE *fout = stdout;

Error 1 error C2099: initializer is not a constant
c:\projects\jmotion\jmotion\jmotion.c 18
Error 2 error C2099: initializer is not a constant
c:\projects\jmotion\jmotion\jmotion.c 19

stdin and stdout need not be constants, so you can't use them to
initalise static or global variables. Do the assignments in an
initialisation function instead.

-- Richard

According to ISO/IEC 14882:2009 Section 8.5, an initializer can be made up
of arbitrary expression so the code has no problem. I've successfully
compiled it by g++ under strict ansi mode.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkrMaVEACgkQG6NzcAXitM8E9ACfRW/XIUL2jvwvcTCASztRDvjt
O5UAn3E/aw2h5+sfwRYdAOyU0eiG75vL
=V8cU
-----END PGP SIGNATURE-----

.



Relevant Pages