Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 552 by PC-Lint accusing errors in atomicops.h and type_traits.h

When checking a source file that includes the protocol buffer library v2.5.0 with PC-Lint 9.00j in VS2010 the following two errors happen:

1) atomicops.h:161:
// Include our platform specific implementation.
#error "Atomic operations are not supported on your platform"

-- PC-Lint does not recognize the #error directive inside the #define.

2) type_traits.h:105:
#if defined(_MSC_VER)
// wchar_t is not by default a distinct type from unsigned short in
// Microsoft C.
// See
template<> struct is_integral<__wchar_t> : true_type { };
template<> struct is_integral<wchar_t> : true_type { };

-- PC-Lint does not have the type __wchar_t defined.

For error number 1), it seems that PC-Lint is right in accusing an preprocessor error and that MSVC just allows that code by chance. There is a similar case when trying to use #pragma warning directives inside a macro definition, where one should use __pragma directives (c.f. Since #error does not have the __error version, one possible solution would be eliminating the #define GOOGLE_PROTOBUF_ATOMICOPS_ERROR and just simply copy paste the #error directive where the symbol GOOGLE_PROTOBUF_ATOMICOPS_ERROR is used. This would have a low-impact since the symbol is used only three times in the same header where it is defined.

For error number 2), PC-Lint is wrong in not defining the type __wchar_t. But looking at the practical side, it seems that the type __wchar_t is not a widely used type, since even microsoft headers don't use it (actually just one C++/CLI header uses it). It was defined in the compiler just to be the type that wchar_t will map to when a compiler option is specified. Even the implementation of is_integral in VS2010's STL doesn't use it directly, what it does is this:
        struct _Is_integral<wchar_t>
                : true_type
        {       // determine whether _Ty is integral

So only when wchar_t is mapped to __wchar_t, then we will define _Is_integral to it.

For better conformance with the is_integral define in the STL, I would suggest using:
#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
template<> struct is_integral<wchar_t> : true_type { };

You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:

You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To post to this group, send email to
Visit this group at
For more options, visit

Reply via email to