Re: error C2099: initializer is not a constant problem
- From: Michael Tsang <miklcct@xxxxxxxxx>
- Date: Wed, 07 Oct 2009 18:11:29 +0800
-----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-----
.
- Follow-Ups:
- Re: error C2099: initializer is not a constant problem
- From: Phil Carmody
- Re: error C2099: initializer is not a constant problem
- From: James Kuyper
- Re: error C2099: initializer is not a constant problem
- References:
- error C2099: initializer is not a constant problem
- From: merrittr
- Re: error C2099: initializer is not a constant problem
- From: Richard Tobin
- error C2099: initializer is not a constant problem
- Prev by Date: Re: small program
- Next by Date: Re: inline trouble with -std=gnu99 (gcc)
- Previous by thread: Re: error C2099: initializer is not a constant problem
- Next by thread: Re: error C2099: initializer is not a constant problem
- Index(es):
Relevant Pages
|