byzhang / rapidjson

Automatically exported from code.google.com/p/rapidjson
MIT License
0 stars 0 forks source link

gcc-4.9.0 compile warnings #111

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am getting compiler warnings, see below.
rev.132.

----
/opt/rapidjson-read-only/include/rapidjson/encodings.h: In static member 
function ‘static CharType 
rapidjson::UTF8<CharType>::TakeBOM(InputByteStream&)’:
/opt/rapidjson-read-only/include/rapidjson/rapidjson.h:115:17: warning: typedef 
‘StaticAssertTypedef170’ locally defined but not used 
[-Wunused-local-typedefs]
  RAPIDJSON_JOIN(StaticAssertTypedef, __LINE__)^M
                 ^
/opt/rapidjson-read-only/include/rapidjson/rapidjson.h:111:34: note: in 
definition of macro ‘RAPIDJSON_DO_JOIN2’
 #define RAPIDJSON_DO_JOIN2(X, Y) X##Y^M
                                  ^
/opt/rapidjson-read-only/include/rapidjson/rapidjson.h:109:30: note: in 
expansion of macro ‘RAPIDJSON_DO_JOIN’
 #define RAPIDJSON_JOIN(X, Y) RAPIDJSON_DO_JOIN(X, Y)^M
                              ^
/opt/rapidjson-read-only/include/rapidjson/rapidjson.h:115:2: note: in 
expansion of macro ‘RAPIDJSON_JOIN’
  RAPIDJSON_JOIN(StaticAssertTypedef, __LINE__)^M
  ^
/opt/rapidjson-read-only/include/rapidjson/encodings.h:170:3: note: in 
expansion of macro ‘RAPIDJSON_STATIC_ASSERT’
   RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1);^M
   ^
/opt/rapidjson-read-only/include/rapidjson/encodings.h: In static member 
function ‘static 
rapidjson::UTF8<CharType>::Chrapidjson::UTF8<CharType>::Take(InputByteStream&)��
�:

/opt/rapidjson-read-only/include/rapidjson/writer.h:228:42: warning: suggest 
braces around empty body in an ‘if’ statement [-Wempty-body]
     RAPIDJSON_ASSERT(type == kStringType);  // if it's in object, then even number should be a name^M
                                          ^
/opt/rapidjson-read-only/include/rapidjson/writer.h:232:63: warning: suggest 
braces around empty body in an ‘else’ statement [-Wempty-body]
    RAPIDJSON_ASSERT(type == kObjectType || type == kArrayType);^M
                                                               ^
/opt/rapidjson-read-only/include/rapidjson/prettywriter.h: In member function 
‘void rapidjson::PrettyWriter<OutputStream, SourceEncoding, TargetEncoding, 
Allocator>::PrettyPrefix(rapidjson::Type)’:
/opt/rapidjson-read-only/include/rapidjson/prettywriter.h:142:42: warning: 
suggest braces around empty body in an ‘if’ statement [-Wempty-body]
     RAPIDJSON_ASSERT(type == kStringType);  // if it's in object, then even number should be a name^M
                                          ^
/opt/rapidjson-read-only/include/rapidjson/prettywriter.h:146:63: warning: 
suggest braces around empty body in an ‘else’ statement [-Wempty-body]
    RAPIDJSON_ASSERT(type == kObjectType || type == kArrayType);^M
                                                               ^
/opt/rapidjson-read-only/include/rapidjson/encodings.h: In static member 
function ‘static 
CharTyperapidjson::UTF8<CharType>::TakeBOM(InputByteStream&)’:

Original issue reported on code.google.com by yuriv...@gmail.com on 1 Jul 2014 at 9:28

GoogleCodeExporter commented 9 years ago
The first one -Wunused-local-typedefs should have been fixed in 

https://github.com/miloyip/rapidjson/commit/1eb62770d33ed00a4ba1d5048b616e4831ee
603a

For the second one -Wempty-body,

I cannot reproduce it in gcc 4.8.x, can you propose a fix method?

For example, 

if (!level->inArray && level->valueCount % 2 == 0)
    RAPIDJSON_ASSERT(type == kStringType);  // if it's in object, then even number should be a name

change to 

if (!level->inArray && level->valueCount % 2 == 0) {
    RAPIDJSON_ASSERT(type == kStringType);  // if it's in object, then even number 
    (void)type;
}

Will this work?

Besides, please note that the repository has been moved to 
https://github.com/miloyip/rapidjson/

Original comment by milo...@gmail.com on 2 Jul 2014 at 1:29