YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
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
20namespace yarp::run::impl {
21
22
23#if defined(YARP_HAS_ACE)
24using std::getenv;
25# if defined(_MSC_VER)
26// ACE bindings for setenv and unsetenv do not work
27// on Visual Studio (last tested ACE 6.4.2, VS 2015).
28inline int setenv(const char* name, const char* value, int overwrite)
29{
30 YARP_UNUSED(overwrite);
31 return _putenv_s(name, value);
32}
33inline int unsetenv(const char* name)
34{
35 return _putenv_s(name, "");
36}
37# else
38using ACE_OS::setenv;
39using ACE_OS::unsetenv;
40# endif
41using ACE_OS::putenv;
42#else
43using std::getenv;
44using ::setenv;
45using ::unsetenv;
46using ::putenv;
47#endif
48
49} // namespace yarp::run::impl
50
51#endif // YARP_RUN_IMPL_PLATFORMSTDLIB_H
#define YARP_UNUSED(var)
Definition api.h:162