MCPcopy Create free account
hub / github.com/numpy/numpy / std_cxx_flags

Function std_cxx_flags

setup.py:242–281  ·  view source on GitHub ↗
(cmd)

Source from the content-addressed store, hash-verified

240 return False
241
242 def std_cxx_flags(cmd):
243 compiler = cmd.compiler
244 flags = getattr(compiler, '__np_cache_cpp_flags', None)
245 if flags is not None:
246 return flags
247 flags = dict(
248 msvc = ['/std:c++17']
249 ).get(compiler.compiler_type, ['-std=c++17'])
250 # These flags are used to compile any C++ source within Numpy.
251 # They are chosen to have very few runtime dependencies.
252 extra_flags = dict(
253 # to update #def __cplusplus with enabled C++ version
254 msvc = ['/Zc:__cplusplus']
255 ).get(compiler.compiler_type, [
256 # The following flag is used to avoid emit any extra code
257 # from STL since extensions are build by C linker and
258 # without C++ runtime dependencies.
259 '-fno-threadsafe-statics',
260 '-D__STDC_VERSION__=0', # for compatibility with C headers
261 '-fno-exceptions', # no exception support
262 '-fno-rtti' # no runtime type information
263 ])
264 if not flags_is_required(compiler, True, flags, textwrap.dedent('''
265 #include <type_traits>
266 template<typename ...T>
267 constexpr bool test_fold = (... && std::is_const_v<T>);
268 int main()
269 {
270 if (test_fold<int, const int>) {
271 return 0;
272 }
273 else {
274 return -1;
275 }
276 }
277 ''&#x27;)):
278 flags.clear()
279 flags += extra_flags
280 setattr(compiler, '__np_cache_cpp_flags', flags)
281 return flags
282
283 def std_c_flags(cmd):
284 compiler = cmd.compiler

Callers 2

build_a_libraryMethod · 0.85
build_extensionMethod · 0.85

Calls 3

flags_is_requiredFunction · 0.85
clearMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected