c++-gtk-utils
|
This library will compile successfully with clang >= 3.3. Clang however has by default a significantly wider set of warnings enabled than does gcc. In particular, it will complain if a template class declared with the struct keyword is specialized using the class keyword, or vice versa.
This is a nuisance because a number of template structs/classes mandated by the C++11/14 standard are intended to be specialized where necessary, most notably std::hash, and (unless the library is compiled with the --without-smart-ptr-comp option) this library does indeed specialize std::hash for Cgu::Callback::FunctorArg, Cgu::Callback::SafeFunctorArg, Cgu::GobjHandle, Cgu::GvarHandle, Cgu::IntrusivePtr, Cgu::SharedHandle, Cgu::SharedLockHandle, Cgu::SharedPtr and Cgu::SharedLockPtr so that objects of such classes may be keys of unordered associative containers. The standard does not specify whether the std::hash template is to be declared as a struct or a class: it only requires that the specialization is to have certain public functions and typedefs. Either declaration is standard conforming and legitimate.
This library declares std::hash specializations as structs, because that is the (non-mandatory) format provided for in ยง20.8.12 of the C++11 standard for the specializations required by the standard. The versions of libstdc++ which come with gcc <= 4.7 do likewise. However the version of libstdc++ which comes with gcc-4.8 declares the std::hash template as a class. This means that if clang is used with the version of libstdc++ which comes with gcc-4.8, by default warnings will be issued when the header files for the classes mentioned above are included in user code.
This can be avoided by compiling user code with clang with the -Wno-mismatched-tags compiler flag.