YARP
Yet Another Robot Platform
PlatformStdlib.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef YARP_RUN_IMPL_PLATFORMSTDLIB_H
7 #define YARP_RUN_IMPL_PLATFORMSTDLIB_H
8 
9 #include <yarp/conf/system.h>
10 #ifdef YARP_HAS_ACE
11 # include <ace/OS_NS_stdlib.h>
12 // In one the ACE headers there is a definition of "main" for WIN32
13 # ifdef main
14 # undef main
15 # endif
16 #else
17 # include <stdlib.h>
18 #endif
19 
20 namespace yarp {
21 namespace run {
22 namespace impl {
23 
24 
25 #if defined(YARP_HAS_ACE)
26 using std::getenv;
27 # if defined(_MSC_VER)
28 // ACE bindings for setenv and unsetenv do not work
29 // on Visual Studio (last tested ACE 6.4.2, VS 2015).
30 inline int setenv(const char* name, const char* value, int overwrite)
31 {
32  YARP_UNUSED(overwrite);
33  return _putenv_s(name, value);
34 }
35 inline int unsetenv(const char* name)
36 {
37  return _putenv_s(name, "");
38 }
39 # else
40 using ACE_OS::setenv;
41 using ACE_OS::unsetenv;
42 # endif
43 using ACE_OS::putenv;
44 #else
45 using std::getenv;
46 using ::setenv;
47 using ::unsetenv;
48 using ::putenv;
49 #endif
50 
51 } // namespace impl
52 } // namespace run
53 } // namespace yarp
54 
55 #endif // YARP_RUN_IMPL_PLATFORMSTDLIB_H
const char * getenv(const char *var)
Portable wrapper for the getenv() function.
Definition: Os.cpp:31
The main, catch-all namespace for YARP.
Definition: dirs.h:16
#define YARP_UNUSED(var)
Definition: api.h:162