Closed Bug 1200039 Opened 9 years ago Closed 9 years ago

VS2015 build fails in calendar/libical: fatal error C1189: Macro definition of snprintf conflicts with Standard Library function declaration

Categories

(Calendar :: Internal Components, defect)

Lightning 4.5
Unspecified
Windows
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: ssitter, Assigned: ssitter)

Details

Attachments

(1 file)

When trying to compile Thunderbird with Lightning using Microsoft Visual Studio 2015 (VC14) on Windows 7 the following error break compilation:

> C:\Program Files (x86)\Windows Kits\10\include\10.0.10150.0\ucrt\stdio.h(1925): 
> warning C4005: 'snprintf': macro redefinition
> 
> [...]/calendar/libical/src/libical/icalrecur.c(143): 
> note: see previous definition of 'snprintf'
> 
> C:\Program Files (x86)\Windows Kits\10\include\10.0.10150.0\ucrt\stdio.h(1927): 
> fatal error C1189: #error:  Macro definition of snprintf conflicts with Standard Library function declaration

Based on my reading snprintf is now available in VS2015, hence the error. 
Maybe we can wrap the define in something like (_MSC_VER < 1900).
http://mxr.mozilla.org/comm-central/source/calendar/libical/src/libical/Makefile.in#39 seems to enforce that the environment has snprintf. Wrapping is certainly an option, but maybe we just have to make some build system changes?
The only place HAVE_SNPRINTF is really used is vsnprintf.c and there it will simply throw a compiler error if not set. Our old copy of libical requires that snprintf is available. On system that don't have snprintf - like VS2013 and older - it just defined snprintf as _snprintf. This was so common that Microsoft added a special check to its header file reporting the error message above.

I'm currently testing a patch similar to the ones in Bug 1119776 + a patch for Bug 1198936, but unfortunately building on Windows takes ages.
This is my current WIP patch. Together with patch from Bug 1198936 the build continues until it tries to link / package non-existing VC++ runtime DLLs.
Attachment #8654650 - Flags: review?(philipp)
Assignee: nobody → ssitter
Status: NEW → ASSIGNED
Comment on attachment 8654650 [details] [diff] [review]
don't define snprintf if MSVC provides it (VS2015 and later do)

Review of attachment 8654650 [details] [diff] [review]:
-----------------------------------------------------------------

lgtm, r=philipp
Attachment #8654650 - Flags: review?(philipp) → review+
Keywords: checkin-needed
https://hg.mozilla.org/comm-central/rev/90e64b5c21bbaba2f657a2f5872d4df3cef0293a
Bug 1200039 - VS2015 build fails in calendar/libical: fatal error C1189: Macro definition of snprintf conflicts with Standard Library function declaration. r=Fallen
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → 4.5
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: