Closed Bug 889136 Opened 11 years ago Closed 11 years ago

MSVC build warning: "usrsctp.h(241) : warning C4200: nonstandard extension used : zero-sized array in struct/union", and similar

Categories

(Core :: WebRTC, defect)

All
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla25

People

(Reporter: dholbert, Assigned: dholbert)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

Quoting a log from an attempt to mark netwerk/sctp/datachannel as FAIL_ON_WARNINGS:
{
DataChannel.cpp

e:\builds\moz2_slave\try-w32-0000000000000000000000\build\netwerk\sctp\src\usrsctp.h(241) : error C2220: warning treated as error - no 'object' file generated

e:\builds\moz2_slave\try-w32-0000000000000000000000\build\netwerk\sctp\src\usrsctp.h(241) : warning C4200: nonstandard extension used : zero-sized array in struct/union

        Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array

e:\builds\moz2_slave\try-w32-0000000000000000000000\build\netwerk\sctp\src\usrsctp.h(350) : warning C4200: nonstandard extension used : zero-sized array in struct/union

        Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array

e:\builds\moz2_slave\try-w32-0000000000000000000000\build\netwerk\sctp\src\usrsctp.h(400) : warning C4200: nonstandard extension used : zero-sized array in struct/union

        Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array

e:\builds\moz2_slave\try-w32-0000000000000000000000\build\netwerk\sctp\src\usrsctp.h(615) : warning C4200: nonstandard extension used : zero-sized array in struct/union

        Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array

e:\builds\moz2_slave\try-w32-0000000000000000000000\build\netwerk\sctp\src\usrsctp.h(626) : warning C4200: nonstandard extension used : zero-sized array in struct/union

        Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array

e:\builds\moz2_slave\try-w32-0000000000000000000000\build\netwerk\sctp\src\usrsctp.h(695) : warning C4200: nonstandard extension used : zero-sized array in struct/union

        Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array

e:\builds\moz2_slave\try-w32-0000000000000000000000\build\netwerk\sctp\src\usrsctp.h(700) : warning C4200: nonstandard extension used : zero-sized array in struct/union

        Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array

e:\builds\moz2_slave\try-w32-0000000000000000000000\build\netwerk\sctp\src\usrsctp.h(765) : warning C4200: nonstandard extension used : zero-sized array in struct/union

        Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array
}
https://tbpl.mozilla.org/php/getParsedLog.php?id=24802161&tree=Try


This is in a third-party library, so rather than trying to fix the code, it might be saner to just disable this warning for this chunk of code. (Fortunately, this is pretty easy in MSVC.)
This patch wraps datachannel's #include of (third-party header) usrsctp.h with "#pragma warning disable" for the warning in question.

See e.g. http://mxr.mozilla.org/mozilla-central/source/content/base/public/nsINode.h?mark=310-314,327-330&rev=731a5fcf1328#310 for another place where we use this technique.

This suppresses the warning, and it lets us build on windows with FAIL_ON_WARNINGS in the datachannel directory as shown by this try push:
https://tbpl.mozilla.org/?tree=Try&rev=5fc593544f85
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Attachment #770064 - Flags: review?(rjesup)
(first version had the commit message split into 2 lines; merged into 1 line here.)
Attachment #770064 - Attachment is obsolete: true
Attachment #770064 - Flags: review?(rjesup)
Attachment #770065 - Flags: review?(rjesup)
(In reply to Daniel Holbert [:dholbert] from comment #1)
> See e.g.
> http://mxr.mozilla.org/mozilla-central/source/content/base/public/nsINode.h?mark=310-314,327-330&rev=731a5fcf1328#310
> for another place where we use this technique.

As an aside, this should be replaced with MOZ_THIS_IN_INITIALIZER_LIST().
(In reply to Masatoshi Kimura [:emk] from comment #3)
> (In reply to Daniel Holbert [:dholbert] from comment #1)
> > See e.g.
> > http://mxr.mozilla.org/mozilla-central/source/content/base/public/nsINode.h?mark=310-314,327-330&rev=731a5fcf1328#310
> > for another place where we use this technique.
> 
> As an aside, this should be replaced with MOZ_THIS_IN_INITIALIZER_LIST().

Sure. I was just linking to it to demonstrate the #pragma syntax for disabling MSVC warnings, but yes, that particular warning (4355) is frequent enough that we have a macro to handle it now. Feel free to file a separate bug on using the macro there. :)
Attachment #770065 - Flags: review?(rjesup) → review+
Flags: in-testsuite-
https://hg.mozilla.org/mozilla-central/rev/477d313cc2ab
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla25
You need to log in before you can comment on or make changes to this bug.