Re: can't initialize a constant using another constant?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

On 2008-02-27 08:09:57 (+0000), Kristof Provost <Kristof@xxxxxxxxxx> wrote:
> On 2008-02-26 20:02:06 (+0530), Shriramana Sharma <samjnaa@xxxxxxxxx> wrote:
> > A strange thing I ran across this evening. I was not allowed to do:
> > 
> > const double lunarSynodicMonth = 29.53059 ;
> > const double daysLunarPhaseAngleTakesPerDegree = lunarSynodicMonth / 360.0 ;
> > 
> > I got the following error:
> > 
> > wdf-karanas.c:17: error: initializer element is not constant
> > make: *** [wdf-karanas.o] Error 1
> > 
> > I would be grateful if anyone could shed some light. TIA.
> What compiler are you using? 
> I did a quick test on g++ 4.1.2 (x86_64) and it seemed to be accepted
> without warning.
I took a better look. I get the same error with gcc.

It looks like this is allowed in C++ and not in plain C (or at least,
g++ allows it and gcc doesn't).

Kristof
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHxSBIUEZ9DhGwDugRAkCiAJoCe+3665vkuJCWxdJTNsu/CxAAzgCePlm4
0OTsa8DQNj/CCG2eKiFrXp4=
=9GTz
-----END PGP SIGNATURE-----
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux