Re: [eigen] Malloc-free dynamic matrices

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


2010/3/4 Gael Guennebaud <gael.guennebaud@xxxxxxxxx>:
>> Regarding runtime settings without a shared lib, I was thinking about
>> using a static variable inside a function:
>>
>> // internal
>> int manage_cache_size(enum action,int v=0)
>> {
>>  static int value = EIGEN_DEFAULT_CACHE_SIZE;
>>   if(action==set) value = v;
>>   if(action==get) return value;
>>   return value;
>>
>> }
>>
>> // public:
>> int cacheSize() { return manage_cache_size(get); }
>> void setCacheSize(int v) { manage_cache_size(set,v); }
>>
>> but I'm really unsure about that...
>
> Looks like I shot my own feet... ;)
> With gcc, if I declare manage_cache_size inline (and not static of course),
> that works fine. I tried with multiple object files calling
> manage_cache_size and also with a shared lib and one application. Is is
> clear enough?

Very clear! and yes your solution is brilliant!

Just one thing, it is REALLY weird to declare it 'inline' as of course
we don't want it actually inlined (actually, it can't be possible to
inline a function that has a static local variable, right?)

I understand that 'inline' here fixes multiple-definitions linking
errors but there's got to be a more kosher way.... man, I'm not good
at all on linker issues, but there's got to be a way without this
dummy 'inline'.

Benoit

>
> gael.
>
>>
>> gael.
>>
>>>
>>> Benoit
>>>
>>>
>>
>
>



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/