From edgarreynaldo at members.allegro.cc Thu Jun 1 19:53:29 2017 From: edgarreynaldo at members.allegro.cc (Edgar Reynaldo) Date: Thu, 1 Jun 2017 14:53:29 -0500 Subject: [theora] Building theora 1.1.1 with mingw-w64-gcc 7.1 and msys Message-ID: <962985ca-0239-c7c8-53b8-3d027a21134b@members.allegro.cc> Hello, I recently attempted to build theora 1.1.1 with mingw-w64-gcc 7.1 and msys and it fails to build the encoder_example.c example program. There are multiple declarations of the function 'rint'. The source file created its own version of the function that rounds AWAY from zero. MinGW-W64 has its own version of the 'rint' function, which does not round away from zero. Therefore, encoder_example.c's rint function is necessary, but needs to be renamed because it includes math.h, which defines "extern __cdecl double rint(double)". Here is the relevant function from encoder_example.c lines 50-62 : #ifdef _WIN32 /*supply missing headers and functions to Win32. going to hell, I know*/ #include #include static double rint(double x) { if (x < 0.0) return (double)(int)(x - 0.5); else return (double)(int)(x + 0.5); } #endif Is this fixed in more recent versions? Should I use 1.2 alpha? Should I build from the latest repository source? Ideas? I'm willing to submit a patch, but I don't know what the resulting function should be renamed. Edgar From edgarreynaldo at members.allegro.cc Thu Jun 1 22:40:45 2017 From: edgarreynaldo at members.allegro.cc (Edgar Reynaldo) Date: Thu, 1 Jun 2017 17:40:45 -0500 Subject: [theora] Building theora 1.1.1 with mingw-w64-gcc 7.1 and msys In-Reply-To: <962985ca-0239-c7c8-53b8-3d027a21134b@members.allegro.cc> References: <962985ca-0239-c7c8-53b8-3d027a21134b@members.allegro.cc> Message-ID: <7907925b-0ea7-97eb-8c15-0e88fc1f4956@members.allegro.cc> Hi people, I fixed the problem by renaming the function and every instance of 'rint' to 'rint_az' (Round Int Away from Zero) and then encoder_example.c built successfully. Don't know if this needs to be patched upstream or not. Edgar On 6/1/2017 2:53 PM, Edgar Reynaldo wrote: > Hello, > > I recently attempted to build theora 1.1.1 with mingw-w64-gcc 7.1 and > msys and it fails to build the encoder_example.c example program. > There are multiple declarations of the function 'rint'. The source > file created its own version of the function that rounds AWAY from > zero. MinGW-W64 has its own version of the 'rint' function, which does > not round away from zero. Therefore, encoder_example.c's rint function > is necessary, but needs to be renamed because it includes math.h, > which defines "extern __cdecl double rint(double)". > > Here is the relevant function from encoder_example.c lines 50-62 : > > #ifdef _WIN32 > /*supply missing headers and functions to Win32. going to hell, I know*/ > #include > #include > > static double rint(double x) > { > if (x < 0.0) > return (double)(int)(x - 0.5); > else > return (double)(int)(x + 0.5); > } > #endif > > Is this fixed in more recent versions? Should I use 1.2 alpha? Should > I build from the latest repository source? Ideas? > > I'm willing to submit a patch, but I don't know what the resulting > function should be renamed. > > Edgar > > > From giles at thaumas.net Thu Jun 1 22:50:00 2017 From: giles at thaumas.net (Ralph Giles) Date: Thu, 1 Jun 2017 15:50:00 -0700 Subject: [theora] Building theora 1.1.1 with mingw-w64-gcc 7.1 and msys In-Reply-To: <7907925b-0ea7-97eb-8c15-0e88fc1f4956@members.allegro.cc> References: <962985ca-0239-c7c8-53b8-3d027a21134b@members.allegro.cc> <7907925b-0ea7-97eb-8c15-0e88fc1f4956@members.allegro.cc> Message-ID: On 2017-06-01 3:40 PM, Edgar Reynaldo wrote: > I fixed the problem by renaming the function and every instance of > 'rint' to 'rint_az' (Round Int Away from Zero) and then > encoder_example.c built successfully. > > Don't know if this needs to be patched upstream or not. Upstream has the same code, so I expect the fix is needed there too. Renaming it means always using the replacement, while a libc which provides it might have a better implementation. Is there a preprocessor define we could use to distinguish it? e.g. #if defined(_WIN32) && !defined(__MINGW__) or something similar. Or you could add a configure check for HAVE_RINT. Note that quite a few of the examples use it. Alternatively, it looks like Visual Studio provides rint these days, so just removing the replacement code might be a viable option. -r