RE: not sure where to post this question... bit C++ implementation specific....

"Luis Villegas" <[email protected]>
Newsgroups gmane.games.devel.general
Message-ID <1CDEE9BCE059E740BF8E6698C6BF2099037273A9@RED-MSG-42.redmond.corp.microsoft.com>
AFAIK the C++ standard disallows declaring arrays with float variables.

Array declarations require "integral constant expressions" which allow
floating literals to be part of the constant as long as a cast is
present to transform these to either integral or enumeration types.
"integral constant expressions" do not allow float variables (even if
they are constant)

In your first example "const int a" is an "integral constant expression"
because it is a const int.

In the second example 5.4f and 3.6f are both floating literals and which
are casted to an int.

The third example uses const floats which are not part of the definition
of "integral const expressions"; therefore the compiler rejects the
code.

Luis Villegas

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
Andras Balogh
Sent: Wednesday, July 07, 2004 8:41 AM
To: [email protected]
Subject: RE: [GD-General] not sure where to post this question... bit
C++ implementation specific....

> How would that help? In C++ you simply cannot do this:
> 
>     int a = 6;
>     int array[a];
> 
> It is not possible to allocate arrays with variables (const or not
const).

I dunno, this compiles fine on MSVC++:

	const int a = 6;
	int array[a];

This also works fine:

	const int a = static_cast<const int>(5.4f / 3.6f);
	int array[a];

But then why it's not possible to do:

	const float a = 14.5f;
	const float b = 2.3f;
	const int c = static_cast<const int>(a / b);
	int array[c];

?


Andras




-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Gamedevlists-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-general
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=557


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Gamedevlists-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-general
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_idU7
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.