[PATCH]: filesystem: Shadow Variables Cause Warnings/Errors When Headers Are Not in System Path
In working through cross-compilation issues with boost, particularly the
filesystem library, I discovered the following error reproduced with the
following test case with both boost 1.34.1 and 1.35.0:
FAILS:
echo "#include
Grant Erickson wrote:
In working through cross-compilation issues with boost, particularly the filesystem library, I discovered the following error reproduced with the following test case with both boost 1.34.1 and 1.35.0:
FAILS: echo "#include
\nint main (void) { return (0); }" | g++ -o test -I/${BuildRoot}/results/boost/include -Werror -Wall -Wshadow -x c++ - PASSES: echo "#include
\nint main (void) { return (0); }" | g++ -o test -I/usr/include -Werror -Wall -Wshadow -x c++ - The failing case complains about 'what', 'path1' and 'path2' argument shadowing in boost/filesystem/path.hpp with respect to like-named member functions.
Since GCC does not enforce warning options on headers in /usr/include, this only shows up when building against a boost installation outside /usr/include, as in the above failure example.
The patch to address this is:
Signed-off-by: Grant Erickson
--- --- boost_1_35_0/boost/filesystem/path.hpp 2008-07-30 16:54:53.000000000 -0700 +++ boost_1_35_0/boost/filesystem/path.hpp.N 2008-07-30 16:59:42.000000000 -0700 @@ -577,23 +577,23 @@ // BOOST_FILESYSTEM_DECL version works for VC++ but not GCC. Go figure! inline const char * what( const char * sys_err_what, - const path & path1, const path & path2, std::string & target ) + const path & path1_arg, const path & path2_arg, std::string & target ) { try { if ( target.empty() ) { target = sys_err_what; - if ( !path1.empty() ) + if ( !path1_arg.empty() ) { target += ": \""; - target += path1.file_string(); + target += path1_arg.file_string(); target += "\""; } - if ( !path2.empty() ) + if ( !path2_arg.empty() ) { target += ", \""; - target += path2.file_string(); + target += path2_arg.file_string(); target += "\""; } }
I've applied this set of changes. The others had already been made. Thanks, --Beman
participants (2)
-
Beman Dawes
-
Grant Erickson