[Vm-dev] [OpenSmalltalk/opensmalltalk-vm] 43c5db: Fix the printf format used in platforms/win32

GitHub noreply at github.com
Wed Jul 20 13:36:05 UTC 2016


  Branch: refs/heads/Cog
  Home:   https://github.com/OpenSmalltalk/opensmalltalk-vm
  Commit: 43c5dba43a5172f6c7864feb0e201b03ae78732b
      https://github.com/OpenSmalltalk/opensmalltalk-vm/commit/43c5dba43a5172f6c7864feb0e201b03ae78732b
  Author: Nicolas Cellier <nicolas.cellier at sirehna.com>
  Date:   2016-07-20 (Wed, 20 Jul 2016)

  Changed paths:
    M platforms/Cross/vm/sqMemoryAccess.h
    M platforms/win32/plugins/B3DAcceleratorPlugin/sqWin32D3D.c
    M platforms/win32/plugins/B3DAcceleratorPlugin/sqWin32OpenGL.c
    M platforms/win32/plugins/HostWindowPlugin/sqWin32HostWindowPlugin.c
    M platforms/win32/plugins/JoystickTabletPlugin/sqWin32Joystick.c
    M platforms/win32/plugins/SocketPlugin/sqWin32NewNet.c
    M platforms/win32/vm/sqWin32Backtrace.c
    M platforms/win32/vm/sqWin32Main.c
    M platforms/win32/vm/sqWin32SpurAlloc.c
    M platforms/win32/vm/sqWin32Utils.c
    M platforms/win32/vm/sqWin32VMProfile.c
    M platforms/win32/vm/sqWin32Window.c

  Log Message:
  -----------
  Fix the printf format used in platforms/win32

Note: the problem is that we do not know if sqInt is int, long or long long.
Same for sqIntptr_t which can be long or long long (on LLP64 like windows x86_64)

So we do not know which format to use, %d %ld or %lld in printf function...
The standard (C99) solution is to use macros for printf format (and scanf format)
See for example http://en.cppreference.com/w/c/types/integer
or http://stackoverflow.com/questions/1255099/whats-the-proper-use-of-printf-to-display-pointers-padded-with-0s

Since we define our own types sqInt sqIntptr_t, we also define our own macros PRIxSQINT PRIxSQPTR etc...
We thus abide to the standard way of doing things...

Hopefully, these changes should eliminate all the -Wformat warning encountered on platforms/win32 in a LLP64 compatible way.
(until we declare the prototype of some implicitely typed functions which might change the deal and uncover more problems).

Similar changes will have to be applied to Smalltalk (slang) code (VMMaker.oscog branch).




More information about the Vm-dev mailing list