[jdk8u-dev] RFR: 8031199: _MSC_VER is only defined on _WIN32

luwang1103 duke at openjdk.org
Mon Jul 8 08:04:00 UTC 2024


hi,
  
When compiling jdk8u from x86_64, there is an alarm message as shown below.
jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c:719:3: note: in expansion of macro ‘TRACE1’
719 |   TRACE1("[GSSLibStub_getCredName] pName=%" PRIuPTR "", (uintptr_t) nameHdl);
    |   ^~~~~~
jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c: In function ‘Java_sun_security_jgss_wrapper_GSSLibStub_importContext’:
jdk/src/share/native/sun/security/jgss/wrapper/NativeUtil.h:92:52: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘long unsigned int’ [-Wformat=]


PRIuPTR is defined in jdk/src/share/native/sun/security/jgss/wrapper/NativeUtil.h

#if _MSC_VER >= 1800
#include<inttypes.h>
#endif

// Visual Studio 2010-2012 doesn't provide inttypes.h so provide appropriate definitions here.
#if _MSC_VER < 1800
#ifdef _LP64
#define PRIuPTR       "I64u"
#else
#define PRIuPTR       "u"
#endif
#endif

Upon checking the code, it was found that the custom macro PRIuPTR was used in the Linux system. The header file # include<inttypes.h> should be used in linux. so, It is necessary to limit the scope of use of custom macros to visual studio 2010-2012.

Thanks!

-------------

Commit messages:
 - 8031199: _MSC_VER is only defined on _WIN32

Changes: https://git.openjdk.org/jdk8u-dev/pull/540/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk8u-dev&pr=540&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8031199
  Stats: 7 lines in 1 file changed: 6 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk8u-dev/pull/540.diff
  Fetch: git fetch https://git.openjdk.org/jdk8u-dev.git pull/540/head:pull/540

PR: https://git.openjdk.org/jdk8u-dev/pull/540


More information about the jdk8u-dev mailing list