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

Noel Llopis <[email protected]>
Newsgroups gmane.games.devel.general
Message-ID <[email protected]>
On Wednesday 07 July 2004 05:23 am, Richard Fabian wrote:
> i seem to be able to safely issue declarations for int initialised
> arrays...
>
> e.g.
>
> 	const int ropeLength = 12.5f;
> 	const int knotSpace = 3.3f;
> 	int array[ (int)( ropeLength / knotSpace ) ];
>
> is perfectly valid.
>
> it looks like it is quite literally the "const float"s that are at
> fault.

If I recall correctly, const floats were treated very differently from const 
ints in VC++. Const floats even generated their own bit of code to be 
executed when they were initialized, whereas const ints became true consts, 
so it doesn't surprise me that they can't be used as part of the array size.

As some other people pointed out earlier, any reason not to use an 
std::vector<> or do dynamic allocation? 

If you don't like having to delete the memory, you can always use 
boost::scoped_array:
boost::scoped_array<int> array (new[ (int)( ropeLength / knotSpace ) ]);


--Noel
Games from Within
http://www.gamesfromwithin.com



-------------------------------------------------------
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
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.