Re: [Crystal-cvs] SF.net SVN: crystal:[39815] CS/trunk/include/csgeom/spatialtree.h

Eric Sunshine <[email protected]> Mon, 30 Sep 2013 17:27:23 -0400
Newsgroups gmane.comp.graphics.crystalspace.devel
Message-ID <CAPig+cRu_5EmPQ7jDpoKf9Jgs+Azp9q_pFNiKmdMiiPy_8CAbw@mail.gmail.com>
On Mon, Sep 30, 2013 at 4:32 PM, Matthieu Kraus
<[email protected]> wrote:
> You can go with an enum then, but please don't use such a c-style
> cast, either use static_cast<int> or use csMin<int> - the code in
> question here is very clean in that regard and I'd really appreciate
> if it stays that way.
>
> Question though: does that only break with 4.8.x and does it work in
> c++11 mode? Because it worked fine for me with VS10 and gcc 4.4.7, so
> if it's only such a recent version where it breaks and if it only
> breaks in c++03 mode I'm not sure it's actually worth working around
> as you should be using c++11 mode with the newer gcc versions, anyway.

Some people are stuck at whatever compiler version is supplied by
their vendor (think Apple and Xcode), so we shouldn't necessarily
assume that using a newer gcc version is an easy option. With a simple
work-around as we have available here (using one of the syntaxes you
suggest above), we should apply it.

-- ES


>
> kind regards,
> RlyDontKnow
>
> Quoting Ralph Campbell <[email protected]>:
>
>> I tried that first actually.
>> Switching to an enum doesn't work because csMin() is defined to use
>> references to T and at least gcc 4.8.1 is gets confused what type to
>> use for the template (int or enum).
>> Doing "maxObjects += csMin(maxObjects+2, (int)objectGrowth);"
>> seems to work though.
>>
>>
>> On Mon, 2013-09-30 at 19:37 +0200, res wrote:
>>> On 30.09.2013 19:25, [email protected] wrote:
>>> > The static variable isn't allocated space anywhere so applications linking
>>> > to the CS library fail to link.
>>> > I didn't see a good place to define it so I did the easy thing and used a
>>> > constant.
>>>
>>> > @@ -415,7 +415,6 @@
>>> >      int numObjects;      // current storage used
>>> >      int maxObjects;      // current storage capacity
>>> >      int estimateObjects; // estimated number of objects in whole tree
>>> > -    static int const objectGrowth = 80; // storage growth minimum
>>> >
>>> >      // Minimum amount of objects in this tree before we consider
>>> splitting.
>>> >      int minSplitObjects;
>>>
>>> I think it's a thing that works in C++11 (becomes a “true“ constant
>>> there), but it results in the static var prob you see above with C++03.
>>> There the workaround is to use an enum:
>>> enum { objectGrowth = 80 };
>>>
>>> -f.r.

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk