Opened 11 years ago
Closed 7 years ago
#6766 closed Bugs (fixed)
incorrect declaration for putenv in config.hpp
| Reported by: | Owned by: | Raffi Enficiaud | |
|---|---|---|---|
| Milestone: | Boost 1.59.0 | Component: | test |
| Version: | Boost 1.49.0 | Severity: | Problem |
| Keywords: | Cc: |
Description
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
Change History (10)
comment:1 by , 10 years ago
| Owner: | changed from to |
|---|
comment:2 by , 8 years ago
I see this failure in my Nightly regression testing in the develop branch when compiling libs/test/src/unit_test_parameters.cpp
"/usr/include/stdlib.h", line 113: Error: putenv(char*) was declared before with a different language. 1 Error(s) detected.
This seems to prevent building of libboost_unit_test_framework.a
...skipped <p/export/users/akumta/BOOST_REGRESSION_patch_local/results/boost/bin.v2/libs/test/build/sun-stlport4/release/link-static/threading-multi>libboost_unit_test_framework.a for lack of <p/export/users/akumta/BOOST_REGRESSION_patch_local/results/boost/bin.v2/libs/test/build/sun-stlport4/release/link-static/threading-multi>unit_test_parameters.o...
Any idea when this fix could go in?
Thank you.
comment:2 by , 8 years ago
I see this failure in my Nightly regression testing in the develop branch when compiling libs/test/src/unit_test_parameters.cpp
"/usr/include/stdlib.h", line 113: Error: putenv(char*) was declared before with a different language. 1 Error(s) detected.
This seems to prevent building of libboost_unit_test_framework.a
...skipped <p/export/users/akumta/BOOST_REGRESSION_patch_local/results/boost/bin.v2/libs/test/build/sun-stlport4/release/link-static/threading-multi>libboost_unit_test_framework.a for lack of <p/export/users/akumta/BOOST_REGRESSION_patch_local/results/boost/bin.v2/libs/test/build/sun-stlport4/release/link-static/threading-multi>unit_test_parameters.o...
Any idea when this fix could go in?
Thank you.
comment:3 by , 8 years ago
The best would be to know which version of the SUNPRO_CC compiler the
extern "C" void putenv
is needed and change this as a workaround for version of the compiler earlier than this one.
The problem is: no one has a Sun here.
Digging a bit more: I can see a similar commit in rev cd47d62b4677b003a75885db5d08d50a1a586bf6 for the execution_monitor.hpp. So why not just having that in the config file?
What version of the compiler do you have right now?
comment:4 by , 8 years ago
I suspect that #include <stdlib.h> was the correct fix even when I put the workaround in originally. If I remember correctly I was running Solaris 10, Sun CC 5.9.
comment:6 by , 8 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
Tentative fix branch tractickets/6766-incorrect-declaration-for-putenv-in-config.hpp, commit 17bef37 (see PR #36)
Waiting for feedback before merging.
comment:7 by , 8 years ago
Branch tractickets/6766-incorrect-declaration-for-putenv-in- config.hpp, commit 17bef37 has been tested with Oracle Solaris Studio compiler and the fix looks good.
This ticket prevents building of libboost_unit_test_framework.a. As a result many tests (from accumulators, algorithm, assign, lexical_cast, msm, odeint, polygon, range and sync) fail due to a dependency on libboost_unit_test_framework.a. The fix significantly improves the pass rate of the test runs by 15% .
We would highly appreciate it if the fix can be putback to develop/master so it can make 1.58 release.
comment:9 by , 7 years ago
| Milestone: | To Be Determined → Boost 1.59.0 |
|---|---|
| Resolution: | → fixed |
| Status: | assigned → closed |

Steven,
This was your addition. I do not have access to this platform anymore. Do you mind looking into this?