[Insight-developers] #include <cXXX> vs. #include <XXX.h>

Bill Lorensen bill.lorensen at gmail.com
Fri Nov 13 12:41:58 EST 2009


strcmp is used in many places in itk. All without the std:: of ::

On Fri, Nov 13, 2009 at 12:39 PM, Tom Vercauteren
<tom.vercauteren at m4x.org> wrote:
> Hi Bill,
>
> I just saw you recent commit to itkUnicodeIOTest:
> http://public.kitware.com/cgi-bin/viewcvs.cgi/Testing/Code/IO/itkUnicodeIOTest.cxx?root=Insight&r1=1.8&r2=1.9
>
> I have a rather generic question about it.
>
> In c style one would include a standard header using XXX.h, e.g.
>  #include <string.h>
>
> In c++, the right way to do it should be to include cXXX, e.g.
>  #include <cstring>
>
> If I understand it correctly
>  #include <string.h>
> is deprecated (but works) in c++ and according to the standard
>  #include <cstring>
> should put all the functions in the std namespace. This means that one
> should not be able to call say strcmp without puting std:: in front of
> it. However, many compilers put the functions in both the std
> namespace and in the default one.
>
> Here come real world problems. Apparently, VS6 does not understand
> std::strcmp (which is a bug) but sun cc does not understand ::strcmp
> (which is correct w.r.t. c++ standard).
> http://www.cdash.org/CDash/viewBuildError.php?buildid=470593
>
> What is the right way of handling this? Use the wrapper from vxl
> (vcl_cstring.h), use the c header string.h, add an ITK wrapper?
>
> Regards,
> Tom
>


More information about the Insight-developers mailing list