On Fri, 15 Apr 2016 11:51:57 -0300, Jeff McKenna wrote:
> Some background information for you, before you respond with "please
> use MinGW" ha:
>
> I distribute libspatialite in MS4W (
http://ms4w.com) for the
> MapServer community (roughly 5,000 downloads per month in fact, and
> increasing).
>
Hi Jeff,
you are too famous to require any self-introduction, your reputation
precedes you.
> gg_extras.c
> src\gaiageo\gg_extras.c(65): error C2491: 'rint': definition of
> dllimport function not allowed
> NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual
> Studio 14.0\VC\BIN\cl.EXE"' : return code '0x2'
> Stop.
>
few useful references:
https://msdn.microsoft.com/en-us/library/dn465165.aspx
https://en.wikipedia.org/wiki/C99
short summary: in the remote 1999 the ISO/IEC 9899:1999
international standard (aka C99) introduced several further
canonic functions expected to be supported by any C compiler,
one of them being rint()
gcc (and consequently MinGW) immediately supported the new
C99 requirements.
Microsoft MSVC was a little bit lazier, and started supporting
C99 only since 2013 and 2015 editions (of course, better late
than never).
> I should note that with the 2008 environment libspatialite compiled
> successfully; however the 2015 compiler throws that error.
>
As we have already seen, any MSVC edition released before
2013 surely lacked a native implementation of rint(), so the
only viable workaround was passing an internal implementation
of rint() when using the MSVC compiler.
It correctly worked on previous versions of MSVC, but it now
fails on 2013 and 2015 editions because the internal rint()
will now conflict with the native MSVC rint().
quick-and-dirty fix:
--------------------
just completely remove the internal rint() implementation
from the gg_extra.c source when using MSVC 2013 or 2015
more sophisticated solution:
----------------------------
after the more recent MSVC/C99 evolutions it's now obvious
the the conditional macro in gg_extra.c sucks:
#if defined(_WIN32) && !defined(__MINGW32__)
testing for a Windows platform and NOT MinGW is too much
simplistic: we are certainly required to perform a deeper
macro test so to correctly discriminate between MSVC-pre-2013
and MSVC-post-2013.
Any possible useful suggestion is warmly welcome and will
be quickly incorporated into the codebase.
bye Sandro