Merge branch 'clang-cl-improvements' into 'master'

Some improvements to clang-cl builds

Closes #2338 and #2357

See merge request GNOME/glib!2004
This commit is contained in:
Philip Withnall 2021-03-31 11:25:56 +00:00
commit 16c4a9a57e
4 changed files with 21 additions and 6 deletions

View File

@ -753,6 +753,7 @@ glib_typeof_2_68
g_macro__has_attribute
g_macro__has_builtin
g_macro__has_feature
g_macro__has_extension
</SECTION>
<SECTION>

View File

@ -276,6 +276,12 @@
#define g_macro__has_builtin(x) 0
#endif
#ifdef __has_extension
#define g_macro__has_extension __has_extension
#else
#define g_macro__has_extension(x) 0
#endif
/**
* G_GNUC_ALLOC_SIZE:
* @x: the index of the argument specifying the allocation size
@ -754,7 +760,8 @@
#ifndef __GI_SCANNER__ /* The static assert macro really confuses the introspection parser */
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
#define G_PASTE(identifier1,identifier2) G_PASTE_ARGS (identifier1, identifier2)
#if !defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#if !defined(__cplusplus) && defined(__STDC_VERSION__) && \
(__STDC_VERSION__ >= 201112L || g_macro__has_feature(c_static_assert) || g_macro__has_extension(c_static_assert))
#define G_STATIC_ASSERT(expr) _Static_assert (expr, "Expression evaluates to false")
#elif (defined(__cplusplus) && __cplusplus >= 201103L) || \
(defined(__cplusplus) && defined (_MSC_VER) && (_MSC_VER >= 1600)) || \

View File

@ -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 ?

View File

@ -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