[Boost-bugs] [Boost C++ Libraries] #6766: incorrect declaration for putenv in config.hpp

Subject: [Boost-bugs] [Boost C++ Libraries] #6766: incorrect declaration for putenv in config.hpp
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-04-05 18:22:26


#6766: incorrect declaration for putenv in config.hpp
----------------------------------------+-----------------------------------
 Reporter: stephen.clamage@… | Owner: rogeeff
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: test
  Version: Boost 1.49.0 | Severity: Problem
 Keywords: |
----------------------------------------+-----------------------------------
 File boost/test/utils/runtime/config.hpp at lines 47-49 has
 {{{
 #ifdef __SUNPRO_CC
 extern int putenv(char *);
 #endif
 }}}
 The immediate problem is that the function is declared as `extern "C"` on
 Solaris, which causes a conflict in BOOST components that include
 <stdlib.h>. A quick fix would be make this declaration `extern "C"`, but
 IMHO that is not the best fix. It addresses the problem only in testing
 BOOST, not necessarily in using BOOST.

 Oracle C++ (SUNPRO_CC) compilers support Linux in addition to Solaris, and
 follow the C++ standard regarding standard headers. Only declarations that
 are part of standard C or C++ appear in the <cxxx> headers. Additional
 declarations appear in the <xxx.h> headers, depending on the platform,
 since most platforms specify additional declarations for the C headers.

 For the case in point, <cstdlib> does not contain a declaration for
 putenv, but <stdlib.h> does, because POSIX specifies putenv as part
 <stdlib.h>.

 My guess is that some BOOST component(s) included <cstdlib> and expected
 to find putenv there -- a non-portable assumption. Somebody tried to fix
 the problem by adding a declaration to config.hpp, but got the declaration
 wrong.

 I recommend removing this hack from config.hpp, and fixing any tests that
 fail by including <stdlib.h> instead of <cstdlib>. That is, if you want a
 POSIX function, you should include a POSIX header.

 After removing the lines, the only failure I have found in BOOST 1.49 is
 libs/test/src/unit_test_parameters.cpp

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6766>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC