Subject: Re: [boost] Warning policy? local variable hides (i.e. shadows) global variable
From: Beman Dawes (bdawes_at_[hidden])
Date: 2015-01-15 12:00:23
On Thu, Jan 15, 2015 at 11:08 AM, Andrey Semashev
>> The "globals" being shadowed are often in the unnamed namespace in
>> user code. So they involve simple names like "n" and "str" which
>> often clash with parameter names, but the library developer has no
>> control over them.
> But in this case the warning is spurious since the library code uses
> its parameters in either case.
That's an interesting point. The user can suppress the warning from
VC++ by wrapping the header include:
#pragma warning (push)
#pragma warning (disable : 4459)
#pragma warning (pop)
I suppose GCC has similar pragmas and other compilers support either
the MSVC or GCC pragmas.
The header itself could provide the pragma's when appropriate (i.e.
the library itself not under test).
> We cannot realistically protect ourselves from such shadowing clashes
> with the code we don't see, unless we follow STLPort route, which
> prepends its names with lots of underscores. I say we shouldn't try
> doing that.
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk