| I had to explicitly add the declaration otherwise things didn't work,
(strangely, not with a segfault or other fatal error but just by
returning zero).
I've found the correct define, it is _GNU_SOURCE (that is 1 underscore
prefix). After defining that, the *_l functions are available.
On Mon, May 20, 2013 at 12:29 PM, wrote:
> I think this confuses be more -- why does my exampler fail and your
> (mostly) work?
>
> If i can find the correct incantation i can change all strtod/strtol/
> whatever fuction calls to ther relevent _l version.
>
> ==John ff
>
>> The strtod_l function seems to exist in glibc as well (I can't seem to
>> get the right -D incantations to make them appear in stdlib.h, but
>> they are there).
>>
>> The following program yields "Value is 3,000000 3,140000 (0)" when
>> using the es_CL locale.
>>
>> Windows seems to have a _strtod_l function too. Perhaps all that is
>> needed is a thin wrapper to these functions.
>>
>>
>> #include
>> #include
>> #include
>> #include
>> #include
>>
>> extern double strtod_l (const char *__restrict __nptr,
>> char **__restrict __endptr,
>> __locale_t __loc);
>>
>> int main(int argc, char** argv) {
>> locale_t c_locale = newlocale (0, "C", NULL);
>> errno = 0;
>> setlocale(LC_ALL, ""); // Force locale from env
>> puts(setlocale(LC_ALL, NULL));
>> double num1 = strtod(argv[1], NULL);
>> double num2 = strtod_l(argv[1], NULL, c_locale);
>> printf("Value is %lf %lf (%d)\n", num1, num2, errno);
>> return 0;
>> }
>>
>> On Mon, May 20, 2013 at 7:42 AM, wrote:
>>> This issue has been around for a bit, and we have been discussing it
>>> off-list and have come to something of an empass.
>>>
>>> The issue is that the Csound parser assues the C locale, but a frontend
>>> or
>>> API user could set the locale to something else. We could set the
>>> locale
>>> repeatedly but that would interact with the uset code, and is not
>>> clearly
>>> thread-safe.
>>>
>>> In BSD (and hence OSX) there is a local loacle version of strtod called
>>> strtod_l which seems to do the correct thing, but the code does not work
>>> on all Linux systems in our tests, and I have no idea what happens in
>>> Windows.
>>>
>>> Does anyone have a clean solution? Or should we implement our own
>>> strtod
>>> etc functions?
>>>
>>> ==John ff
>>>
>>> test-program:
>>>
>>> #include
>>> #include
>>> #include
>>> #include
>>> #include
>>>
>>> int main(int argc, char** argv) {
>>> locale_t c_locale = newlocale (LC_ALL_MASK, "C", 0);
>>> errno = 0;
>>> printf("Value is %f (%d)\n", strtod_l(argv[1], NULL, c_locale),
>>> errno);
>>> return 0;
>>> }
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> AlienVault Unified Security Management (USM) platform delivers complete
>>> security visibility with the essential security capabilities. Easily and
>>> efficiently configure, manage, and operate all of your security controls
>>> from a single console and one unified framework. Download a free trial.
>>> http://p.sf.net/sfu/alienvault_d2d
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>>
>>
>> --
>>
>> Saludos,
>> Felipe Sateler
>>
>> ------------------------------------------------------------------------------
>> AlienVault Unified Security Management (USM) platform delivers complete
>> security visibility with the essential security capabilities. Easily and
>> efficiently configure, manage, and operate all of your security controls
>> from a single console and one unified framework. Download a free trial.
>> http://p.sf.net/sfu/alienvault_d2d
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>>
>>
>
>
>
> ------------------------------------------------------------------------------
> AlienVault Unified Security Management (USM) platform delivers complete
> security visibility with the essential security capabilities. Easily and
> efficiently configure, manage, and operate all of your security controls
> from a single console and one unified framework. Download a free trial.
> http://p.sf.net/sfu/alienvault_d2d
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
--
Saludos,
Felipe Sateler
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net |