[CDRIVER-2249] Thousands of warnings with MSVC like "'4' bytes padding added after data member" Created: 21/Aug/17  Updated: 28/Oct/23  Resolved: 23/Aug/17

Status: Closed
Project: C Driver
Component/s: Build
Affects Version/s: 1.7.0
Fix Version/s: 1.8.0

Type: Bug Priority: Minor - P4
Reporter: A. Jesse Jiryu Davis Assignee: A. Jesse Jiryu Davis
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

As a consequence of adding the ENABLE_MAINTAINER_FLAGS option to CMakeLists.txt:

https://github.com/mongodb/mongo-c-driver/commit/34c5c96985eb9bdcb669502cf7cd126fb21c4248

There are now thousands of worthless warnings like this when compiling with MSVC in our Evergreen build:

https://github.com/mongodb/mongo-c-driver/commit/34c5c96985eb9bdcb669502cf7cd126fb21c4248
         c:\cygwin\home\administrator\mongo-c-driver\src\libbson\src\bson\bson-types.h(297): warning C4820: '<unnamed-tag>': '4' bytes padding added after data member 'data_len' [C:\cygwin\home\Administrator\mongo-c-driver\src\libbson\test-libbson.vcxproj]

The problem seems to be MSVC can accept the "-Wall" flag, but it's badly implemented. MSVC shouldn't warn about code in system headers, but it does, and perhaps these "padding" warnings are completely spurious no matter where they originate.

MSVC doesn't accept any other GCC-style warning options like "-Wformat", so it's a waste of time for CMake to check each of them.

To resolve this, let's skip the entire warning-flags configuration step if the compiler is MSVC.



 Comments   
Comment by Ramon Fernandez Marina [ 12/Sep/17 ]

Author:

{'username': u'ajdavis', 'name': u'A. Jesse Jiryu Davis', 'email': u'jesse@mongodb.com'}

Message:CDRIVER-2249 don't set maintainer flags with MSVC

MSVC accepts "-Wall" but it results in thousands of spurious warnings.
It doesn't accept any other GCC-style flags like "-Wformat", so CMake
wastes time checking them all. To solve both problems, just skip the
maintainer flags configuration with MSVC.
Branch:master
https://github.com/mongodb/mongo-c-driver/commit/b9f2ff2426784362b9521a72261c1470013a8101

Comment by Ramon Fernandez Marina [ 12/Sep/17 ]

Author:

{'username': u'ajdavis', 'name': u'A. Jesse Jiryu Davis', 'email': u'jesse@mongodb.com'}

Message:CDRIVER-2249 don't set maintainer flags with MSVC

MSVC accepts "-Wall" but it results in thousands of spurious warnings.
It doesn't accept any other GCC-style flags like "-Wformat", so CMake
wastes time checking them all. To solve both problems, just skip the
maintainer flags configuration with MSVC.
Branch:master
https://github.com/mongodb/libbson/commit/28077f6ff1f1dfd523d4fdda619dae2c9b4347a3

Comment by A. Jesse Jiryu Davis [ 23/Aug/17 ]

https://github.com/mongodb/libbson/commit/28077f6ff1f1dfd523d4fdda619dae2c9b4347a3

https://github.com/mongodb/mongo-c-driver/commit/b9f2ff2426784362b9521a72261c1470013a8101

Generated at Wed Feb 07 21:14:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.