|
Boost : |
From: Beman Dawes (beman_at_[hidden])
Date: 1999-09-28 18:11:41
John Maddock wrote:
>I wonder if it is worth while having a standard policy to deal with the old
>C style headers, the problem is that while most current compilers ship with
>the <cname> header variants, not all of them place the contents in
>namespace std. There would appear to be three workarounds:
>
>1) Always use the <name.h> approach - the primary advantage is that this
>always works, but pollutes the global namespace.
I dislike this approach. Yes, there is a problem, but let's try to wean
people away from the .h C headers. We should aim toward better namespace
discipline even if we can't achieve 100% of ideal yet.
>2) Use the <cname> version along with the workaround:
>
>#include <cname>
>
>namespace std{} // dummy in case not alway defined
>
>namespace boost{ namespace internal{
>
>using namespace std;
>
>/* code goes here */
>
>}
>}
2) is my preference for .cpp files. But also check the C header is needed
at all. I have caught myself using <climits> for problems better solved
via <limits>.
>3) use the <cname> version along with a macro BOOST_STDC which is defined
>to either <nothing> or std depending upon the compiler:
>
>#include <cname>
>
>namespace boost{ namespace internal{
>
>// here we can refer to BOOST_STDC::cfunction etc
>
>/* code goes here */
>
>}
>}
While some (non-boost) libraries use this technique, it strikes me as ugly.
Just a personal opinion. But it does seem like we are caught between a
rock and a hard place.
>Option (2) is probably the easiest for .cpp files but I don't fancy it in
>headers (for template code for example), which leaves option (3), any
>thoughts?
Agreed that it would be nice to keep it out of headers.
What do others think?
--Beman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk