The default bug view has changed. See this FAQ.

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

RESOLVED FIXED in 4.5

Status

Calendar
Internal Components
RESOLVED FIXED
2 years ago
2 years ago

People

(Reporter: Stefan Sitter, Assigned: Stefan Sitter)

Tracking

Lightning 4.5
Unspecified
Windows

Details

Attachments

(1 attachment)

(Assignee)

Description

2 years ago
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?
(Assignee)

Comment 2

2 years ago
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.
(Assignee)

Comment 3

2 years ago
Created attachment 8654650 [details] [diff] [review]
don't define snprintf if MSVC provides it (VS2015 and later do)

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.
(Assignee)

Updated

2 years ago
Attachment #8654650 - Flags: review?(philipp)
(Assignee)

Updated

2 years ago
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+
(Assignee)

Updated

2 years ago
Keywords: checkin-needed

Comment 5

2 years ago
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

Updated

2 years ago
Status: ASSIGNED → RESOLVED
Last Resolved: 2 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.