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