Skip to content

Commit a7e6014

Browse files
authored
fix: macOSのclangでビルドが失敗する問題を修正
1 parent 7314d48 commit a7e6014

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

meson.build

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,21 @@ add_project_arguments('-I' + meson.current_source_dir() / 'include', language: '
133133
# include-internalを追加
134134
add_project_arguments('-I' + meson.current_source_dir() / 'include-internal', language: 'cpp')
135135

136+
# macOSでは_LIBCPP_ENABLE_ASSERTIONSを無効化
137+
#
138+
# NOTE: Apple ClangとMesonの齟齬によるもの。
139+
# https://github.com/mesonbuild/meson/issues/13812 はまだ治らなそう。
140+
# https://github.com/mesonbuild/meson/pull/14548 がマージされているので、そのうち治るはず。
141+
if host_system == 'darwin'
142+
add_project_arguments('-U_LIBCPP_HARDENING_MODE', language: 'cpp')
143+
add_project_arguments('-U_LIBCPP_ENABLE_ASSERTIONS', language: 'cpp')
144+
if get_option('buildtype') == 'debug'
145+
add_project_arguments('-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE', language: 'cpp')
146+
else
147+
add_project_arguments('-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE', language: 'cpp')
148+
endif
149+
endif
150+
136151
# 追加のコンパイラフラグを生成
137152
cpp_args = []
138153
if get_option('enable_vvl')
@@ -154,19 +169,6 @@ if host_system == 'windows'
154169
endif
155170
endif
156171

157-
# macOSでは_LIBCPP_ENABLE_ASSERTIONSを無効化
158-
#
159-
# NOTE: Apple ClangとMesonの齟齬によるもの。
160-
# https://github.com/mesonbuild/meson/pull/14548 がマージされているので、そのうち治るはず。
161-
if host_system == 'darwin'
162-
cpp_args += ['-U_LIBCPP_ENABLE_ASSERTIONS']
163-
if get_option('buildtype') == 'debug'
164-
cpp_args += ['-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE']
165-
else
166-
cpp_args += ['-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE']
167-
endif
168-
endif
169-
170172
# prefixとsufixを指定
171173
#
172174
# NOTE: MesonではたといWindowsであってもlibxxx.aという命名でライブラリを作る。

src/audio/_stb_vorbis.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@
44
// NOTE: MSVCで警告が出てビルドが失敗するので、stb_vorbis.cだけ例外的に警告を無効化する。
55
#pragma warning(push)
66
#pragma warning(disable : 4244 4245 4456 4457 4701)
7+
#elif defined(__clang__)
8+
// NOTE: Clangで警告が出てビルドが失敗するので、stb_vorbis.cだけ例外的に警告を無効化する。
9+
#pragma clang diagnostic push
10+
#pragma clang diagnostic ignored "-Wtautological-compare"
711
#endif
812

913
#define STB_VORBIS_IMPLEMENTATION
1014
#include <stb_vorbis.c>
1115

1216
#ifdef _MSC_VER
1317
#pragma warning(pop)
18+
#elif defined(__clang__)
19+
#pragma clang diagnostic pop
1420
#endif

0 commit comments

Comments
 (0)