Skip to content

Cygwin build generates warnings on macro SDL_PRIs64 in events/SDL_events.c #5025

@rioj7

Description

@rioj7

Building SDL2-2.0.16 on cygwin with

mkdir build ; cd build
../configure
make

Generates warnings of the kind

src/events/SDL_events.c:342:53: warning: format '%d' expects argument of type 'int', but argument 5 has type 'long long int' [-Wformat=]
    SDL_snprintf(details, sizeof (details), " (timestamp=%u touchid=%"SDL_PRIs64" fingerid=%"SDL_PRIs64" x=%f y=%f dx=%f dy=%f pressure=%f)",
src/events/SDL_events.c:346:40: note: in expansion of macro 'PRINT_FINGER_EVENT'
         SDL_EVENT_CASE(SDL_FINGERDOWN) PRINT_FINGER_EVENT(event); break;
                                        ^~~~~~~~~~~~~~~~~~
src/events/SDL_events.c:38:25: note: format string is defined here
 #define SDL_PRIs64  "I64d"

Looking at the definition of SDL_PRIs64 at src/events/SDL_events.c:37

#undef SDL_PRIs64
#ifdef __WIN32__
#define SDL_PRIs64  "I64d"
#else
#define SDL_PRIs64  "lld"
#endif

For some reason __WIN32__ is defined.

If I use a simple test program it turns out not to be defined

#include <stdio.h>

int main() {
#if defined(__WIN32__)
  printf("defined: __WIN32__\n");
#endif
#if defined(__CYGWIN__)
  printf("defined: __CYGWIN__\n");
#endif
#if defined(__linux__)
  printf("defined: __linux__\n");
#endif
#if defined(_WIN32)
  printf("defined: _WIN32\n");
#endif
#if defined(_WIN64)
  printf("defined: _WIN64\n");
#endif
#if defined(__GNUC__)
  printf("defined: __GNUC__\n");
#endif
#if defined(__clang__)
  printf("defined: __clang__\n");
#endif
#if defined(__MINGW32__)
  printf("defined: __MINGW32__\n");
#endif
#if defined(__MINGW64__)
  printf("defined: __MINGW64__\n");
#endif
}

If I change the definition of SDL_PRIs64 at src/events/SDL_events.c:37 to

#undef SDL_PRIs64
#ifdef __WIN32__
#ifdef __CYGWIN__
#define SDL_PRIs64  "lld"
#else
#define SDL_PRIs64  "I64d"
#endif
#else
#define SDL_PRIs64  "lld"
#endif

the compilation warnings are gone.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions