This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: builtin sscanf
- From: fedor_qd <fedor_qd at mail dot ru>
- To: Jeff Law <law at redhat dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 19 Oct 2016 21:45:43 +0300
- Subject: Re: builtin sscanf
- Authentication-results: sourceware.org; auth=none
- Authentication-results: smtp38.i.mail.ru; auth=pass smtp.auth=fedor_qd at mail dot ru smtp.mailfrom=fedor_qd at mail dot ru
How precize this function?
I write sample:
int main()
{
float x, y;
__builtin_sscanf("30,981", "%f", &x);
__builtin_printf("Test comma: %f\n", x);
return(0);
}
Compile with options: g++ main.c -o hello -static-libgcc
This sample returns 30.00 but 30.981 expected
Always yours, Strizhniou Fiodar
Всегда ваш, Стрижнёв Фёдор
Пользователь Jeff Law <law@redhat.com> писал:
>On 10/13/2016 01:03 AM, fedor_qd@mail.ru wrote:
>> Are GCC builtin function sscanf, strtod and atof independent from libc provided by os?
>> Always yours, Fiodar Stryzniou
>They are largely independent -- though GCC has knowledge of the
>requirements imposed by POSIX and assumes those requirements except in a
>freestanding implementation.
>
>GCC sometimes has small amounts of knowledge of the implementation. For
>example, it knows about how the implmementation handles certain
>formatting which vary across implemetations (%p for example). That
>knowledge is used to give more precise buffer overflow warnings and can
>be used to optimize return values from certain *printf calls.
>
>Jeff