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

Tom Vercauteren tom.vercauteren at m4x.org
Fri Nov 13 12:39:56 EST 2009


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