-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove usage of "lg" in printf format #102
Conversation
@9fcc This change fixes the issue with MinGW and does not change the output of any of the tests. The MinGW tests are now enabled. Can you review the change? |
@@ -673,7 +673,7 @@ CK_DLL_EXP void CK_EXPORT _ck_assert_failed(const char *file, int line, | |||
|
|||
/* Number of digits after the decimal point to output via printf */ | |||
#ifndef CK_FLOATING_DIG | |||
# define CK_FLOATING_DIG 6 | |||
# define CK_FLOATING_DIG "6" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not like an idea that precision might be a string. It gives users possibility to add hacks to Checks... And I am sure that somebody will use this possibility for their needs while it would lead problems afterwards. Writing 06, +6 would cause different situations too.
But using #CK_FLOATING_DIG would cause more problems since it would be the same as string in fact.
If there is no way to pass number for precision than changes are good to go. |
MinGW on Windows does not "lg". The reason is that MinGW mixes GCC and the MSVC runtime. For GCC a long double is either 96-bit or 128-bit type for long double on x86 or x64 targets (see http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html). However, MSVC uses a 64-bit type (see http://msdn.microsoft.com/en-us/library/9cx8xs15.aspx). That means for MSVC "double" and "long double" are the same. Because of this mismatch, the "l" in "lg", which is safely ignored on Linux and BSD systems is not safely ignored in MSVC systems where GCC is used to compile. This issue does not arise when using VS compiler on Windows.
f088df8
to
5dcd72e
Compare
Removing just the "l" from "lg" was enough to resolve the issue. The precision change was unnecessary. |
Jenkins: test this please |
MinGW on Windows does not "lg". The reason is that MinGW mixes
GCC and the MSVC runtime. For GCC a long double is either
96-bit or 128-bit type for long double on x86 or x64 targets
(see http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html).
However, MSVC uses a 64-bit type
(see http://msdn.microsoft.com/en-us/library/9cx8xs15.aspx).
That means for MSVC "double" and "long double" are the same.
Because of this mismatch, the "l" in "lg", which is safely ignored
on Linux and BSD systems is not safely ignored in MSVC systems
where GCC is used to compile. This issue does not arise when using
VS compiler on Windows.
Credit for explaining this problem goes here: http://stackoverflow.com/questions/7134547/gcc-printf-and-long-double-leads-to-wrong-output-c-type-conversion-messes-u
#101