linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kristof Provost <Kristof@sigsegv.be>
To: Shriramana Sharma <samjnaa@gmail.com>
Cc: Linux C Programming List <linux-c-programming@vger.kernel.org>
Subject: Re: can't initialize a constant using another constant?
Date: Wed, 27 Feb 2008 08:33:12 +0000	[thread overview]
Message-ID: <20080227083312.GC13641@nereid> (raw)
In-Reply-To: <20080227080957.GB13641@nereid>

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

On 2008-02-27 08:09:57 (+0000), Kristof Provost <Kristof@sigsegv.be> wrote:
> On 2008-02-26 20:02:06 (+0530), Shriramana Sharma <samjnaa@gmail.com> 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-----

  reply	other threads:[~2008-02-27  8:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-26 14:32 can't initialize a constant using another constant? Shriramana Sharma
2008-02-27  8:09 ` Kristof Provost
2008-02-27  8:33   ` Kristof Provost [this message]
2008-02-27 11:43 ` Glynn Clements
2008-02-27 23:35   ` Shriramana Sharma
2008-02-28  9:52     ` Glynn Clements

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080227083312.GC13641@nereid \
    --to=kristof@sigsegv.be \
    --cc=linux-c-programming@vger.kernel.org \
    --cc=samjnaa@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).