Re: [eigen] Malloc-free dynamic matrices |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Malloc-free dynamic matrices
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Thu, 4 Mar 2010 16:49:06 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=ZuSg7bZrf6aesCNzl6sOjt5IruTRGOT0gaxNNL81jOA=; b=kMC/KJtUImRzApQQ4asUN/GZWlFwnafU3Cv9J6XF7jQ1cktkbZgVgz88dGh7XmS0Gt 3RsqBSVIoWLsYkuRoIJZ9wIQcSJ7UMdZWFGWd9RQsXDHoRCPzf8R2XLZS/v56X1PLKPl PJ9Ke1nzbbPO+erhVusvAyX5uCdr1W+Vsa4G8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=lOnwJDgvKEanw1FRsf1ZtX97FPoX5rsAlSLhQr5l0GveImBpxIeCvCIfAF3zaqCej9 NQU2ghyv4b6AjmPC5q8wt4DYrQpkhrOFpXfTRgMmyqK8Vw3/r/Y8/hzltjG+l0o+yswm CA75r1XLPZJYGPXLUUy8mxGnO8sUoCorRBkrI=
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
>>>
>>>
>>
>
>