mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 22:46:15 +01:00
msvc_recommended_pragmas.h: Refine for clang-cl
Make msvc_recommended_pragmas.h work better with clang-cl so that we can use that to eliminate some warnings that are emitted as it also consumes Microsoft compiler and SDK headers. Also, for GLib builds, force-include msvc_recommended_pragmas.h for clang-cl builds as well, as it becomes usable and useful there. Fixes issue #2357.
This commit is contained in:
parent
622b31f69e
commit
97959cd7eb
13
meson.build
13
meson.build
@ -14,18 +14,23 @@ cxx = meson.get_compiler('cpp')
|
||||
|
||||
cc_can_run = not meson.is_cross_build() or meson.has_exe_wrapper()
|
||||
|
||||
if cc.get_id() == 'msvc'
|
||||
if cc.get_argument_syntax() == 'msvc'
|
||||
# Ignore several spurious warnings for things glib does very commonly
|
||||
# (also for clang-cl)
|
||||
add_project_arguments('/FImsvc_recommended_pragmas.h',language : 'c')
|
||||
endif
|
||||
|
||||
if cc.get_id() == 'msvc'
|
||||
# If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
|
||||
# If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
|
||||
# NOTE: Only add warnings here if you are sure they're spurious
|
||||
add_project_arguments('/wd4035', '/wd4715', '/wd4116',
|
||||
'/wd4046', '/wd4068', '/wo4090', '/FImsvc_recommended_pragmas.h',language : 'c')
|
||||
'/wd4046', '/wd4068', '/wo4090',language : 'c')
|
||||
# Set the input and exec encoding to utf-8, like is the default with GCC
|
||||
add_project_arguments(cc.get_supported_arguments(['/utf-8']), language: 'c')
|
||||
# Disable SAFESEH with MSVC for plugins and libs that use external deps that
|
||||
# are built with MinGW
|
||||
noseh_link_args = ['/SAFESEH:NO']
|
||||
# Set the input and exec encoding to utf-8, like is the default with GCC
|
||||
add_project_arguments(cc.get_supported_arguments(['/utf-8']), language: 'c')
|
||||
else
|
||||
noseh_link_args = []
|
||||
# -mms-bitfields vs -fnative-struct ?
|
||||
|
@ -1,10 +1,11 @@
|
||||
#ifndef _MSC_VER
|
||||
#pragma error "This header is for Microsoft VC only."
|
||||
#pragma error "This header is for Microsoft VC or clang-cl only."
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/* Make MSVC more pedantic, this is a recommended pragma list
|
||||
* from _Win32_Programming_ by Rector and Newcomer.
|
||||
*/
|
||||
#ifndef __clang__
|
||||
#pragma warning(error:4002) /* too many actual parameters for macro */
|
||||
#pragma warning(error:4003) /* not enough actual parameters for macro */
|
||||
#pragma warning(1:4010) /* single-line comment contains line-continuation character */
|
||||
@ -33,6 +34,7 @@
|
||||
#pragma warning(disable:4305) /* No truncation from int to char warnings */
|
||||
|
||||
#pragma warning(error:4819) /* The file contains a character that cannot be represented in the current code page */
|
||||
#endif /* __clang__ */
|
||||
|
||||
/* work around Microsoft's premature attempt to deprecate the C-Library */
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
Loading…
Reference in New Issue
Block a user