catch_getenv.cpp
1 2 // Copyright Catch2 Authors 3 // Distributed under the Boost Software License, Version 1.0. 4 // (See accompanying file LICENSE.txt or copy at 5 // https://www.boost.org/LICENSE_1_0.txt) 6 7 // SPDX-License-Identifier: BSL-1.0 8 9 #include <catch2/internal/catch_getenv.hpp> 10 11 #include <catch2/internal/catch_platform.hpp> 12 #include <catch2/internal/catch_compiler_capabilities.hpp> 13 14 #include <cstdlib> 15 16 namespace Catch { 17 namespace Detail { 18 19 #if !defined (CATCH_CONFIG_GETENV) 20 char const* getEnv( char const* ) { return nullptr; } 21 #else 22 23 char const* getEnv( char const* varName ) { 24 # if defined( _MSC_VER ) 25 # pragma warning( push ) 26 # pragma warning( disable : 4996 ) // use getenv_s instead of getenv 27 # endif 28 29 return std::getenv( varName ); 30 31 # if defined( _MSC_VER ) 32 # pragma warning( pop ) 33 # endif 34 } 35 #endif 36 } // namespace Detail 37 } // namespace Catch