Anybody knows the reason for the following code (you can see it in flac/decode.c, flac/encode.c, libFLAC/fixed.c and libFLAC/stream_decoder.c) ? #if defined _MSC_VER || defined __MINGW32__ /* with MSVC you have to spoon feed it the casting */ residual_bits_per_sample[0] = (FLAC__float)((total_error_0 > 0) ? log(M_LN2 * (FLAC__double)(FLAC__int64)total_error_0 / (FLAC__double)data_len) / M_LN2 : 0.0); ... #else residual_bits_per_sample[0] = (FLAC__float)((total_error_0 > 0) ? log(M_LN2 * (FLAC__double)total_error_0 / (FLAC__double)data_len) / M_LN2 : 0.0); ... #endif IOW: use (FLAC__double)(FLAC__int64)some_uint64_variable for MSVC and MinGW and (FLAC__double)some_uint64_variable for other compilers. relevant patches: http://git.xiph.org/?p=flac.git;a=commitdiff;h=59f4a995ddf0632241116bd69f6dc8c6f3ac790c (april 2001) http://git.xiph.org/?p=flac.git;a=commitdiff;h=40333b13c127bfb3c5f839fb59edbafa23d3ccbb (this patch is probably just a mass rename from _MSC_VER to _MSC_VER + __MINGW32__). Is it MSVC6 specific? The following web pages seem to confirm this: http://www.winehq.org/pipermail/wine-patches/2004-September/012502.html https://mail.gnome.org/archives/commits-list/2012-July/msg01092.html
lvqcl wrote:> Anybody knows the reason for the following code > (you can see it in flac/decode.c, flac/encode.c, libFLAC/fixed.c and > libFLAC/stream_decoder.c) ?<snip>> Is it MSVC6 specific? The following web pages seem to confirm this: > http://www.winehq.org/pipermail/wine-patches/2004-September/012502.html > https://mail.gnome.org/archives/commits-list/2012-July/msg01092.htmlThat's a really good question. Haven't was already dropped support for MSVC6? If so, we should drop this #ifdef hackery. Can test this without the hackery for versions of MSVC > 6? Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
Erik de Castro Lopo wrote:> That's a really good question. Haven't was already dropped support for > MSVC6? If so, we should drop this #ifdef hackery. Can test this without > the hackery for versions of MSVC > 6?I don't have VC 2002/2003, but the oldest Visual Studio that FLAC supports is MSVS 2005 anyway. It can compile FLAC__uint64 -> FLAC__double conversion without intermediate FLAC__int64. So this "spoon feed" isn't necessary. (found another place with this double conversion, inside src/utils/flactimer/main.cpp. It also has unnecessary #defines for int64_t/uint64_t)