gsoap bug under windows: %lld or…

来源:互联网 发布:c语言 经典书籍 pdf 编辑:程序博客网 时间:2024/05/21 09:59

gsoap bug under windows: %lld or %I64d

 

Zhang X.

Aug 30, 2010

 

gSoap is an open source tool to support Web service withcross-platform support.

Recently we find a small bug in gsoap-created source code onWindows/Windows moble

platform, which is related to __int64 encode to and decode fromXML string.

 

gSoap default code to handle XML string of __int64 is like:

        // APIs in stdsoap2.cpp

         xxxsoap_LONG642s(...)

        {

             sprint(s,"%lld",__int64_value); // to fix the bug, use "%I64d" onWindows

        }

   and

        xxxsoap_s2LONG64(...)

       

           // also, sscanf(.....)  // to fix the bug, use"%I64d"

       }

 

The root cause is simple. Although the code works on UNIX/LINUXplatform.

On windows-family platforms, you should use "I64d" to format__int64 value.

So the final solution could be very simple, you just need use"%I64d" to

take the place of "%lld" with code being #ifdef _WIN32 macrocovered.

 

0 0
原创粉丝点击