diff --git a/ChangeLog b/ChangeLog index c8290fb473985c33bac745f49327cf318cd7d629..3c624b7a1f78894ae0750e373e7c0905736dc967 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,32 @@ +2021-05-23 David Turner + + * src/ftmemchk.c: Remove minor compiler warning. + + Casting a pointer to (long) isn't always correct. + +2021-05-23 David Turner + + * src/ftpngout.c: Remove compiler warning for Mingw64 toolchain. + + The #pragma statement is only valid with Microsoft Visual C++ + +2021-05-23 David Turner + + * graph/win32/grwin32.c: Fix compiler warnings + + - Redefine the LCS_sRGB macro to properly compile with the Mingw64 + toolchain and the -Wmultichar warning enabled. + + - Add missing return code paths in function. + +2021-05-22 David Turner + + * src/ftbench.c: Fix get_time() for Mingw64 + + clock_gettime() cannot be used when cross-compiling for Windows + using the Linux Mingw64 toolchain, so ensure the Win32-specific + timer code is always used when _WIN32 is defined. + 2021-05-24 David Turner [build] Add Meson build files and documentation. diff --git a/graph/win32/grwin32.c b/graph/win32/grwin32.c index 799e4e35ab4ccd8a25e6d9d32d197ede962263e6..a078a57945f8bfbf0ad8de069009e37583439260 100644 --- a/graph/win32/grwin32.c +++ b/graph/win32/grwin32.c @@ -256,6 +256,15 @@ gr_win32_surface_set_icon( grWin32Surface* surface, ICONINFO ici = { TRUE }; HICON hIcon; +/* NOTE: The Mingw64 wingdi.h defines this macro as 'sRGB' + * which triggers the -Wmultichar warning during compilation, + * so replace it with the corresponding numerical value. + */ +#ifdef __MINGW64__ +#undef LCS_sRGB +#define LCS_sRGB 0x73524742 +#endif + BITMAPV4HEADER hdr = { sizeof( BITMAPV4HEADER ), 0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000, @@ -297,6 +306,8 @@ gr_win32_surface_set_icon( grWin32Surface* surface, case ICON_BIG: surface->bIcon = hIcon; return s[0]; + default: + return 0; /* should not happen */ } } diff --git a/src/ftbench.c b/src/ftbench.c index 37e8e0e0b3ac53dd27f5020f14992ab044cdbae6..592fcff9f2dba222eadd3c914fc1f32d723d54e4 100644 --- a/src/ftbench.c +++ b/src/ftbench.c @@ -198,19 +198,11 @@ static double get_time( void ) { -#if defined _POSIX_TIMERS && _POSIX_TIMERS > 0 - struct timespec tv; - - -#ifdef _POSIX_CPUTIME - clock_gettime( CLOCK_PROCESS_CPUTIME_ID, &tv ); -#else - clock_gettime( CLOCK_REALTIME, &tv ); -#endif /* _POSIX_CPUTIME */ - - return 1E6 * (double)tv.tv_sec + 1E-3 * (double)tv.tv_nsec; - -#elif defined _WIN32 +/* NOTE: When building with the Mingw64 toolchain, _POSIX_TIMERS + * will be defined, but clock_gettime() won't, so ensure that the + * _WIN32 specific timer code appears first here. + */ +#if defined _WIN32 #ifdef QPC LARGE_INTEGER ticks; @@ -238,6 +230,18 @@ #endif +#elif defined _POSIX_TIMERS && _POSIX_TIMERS > 0 + struct timespec tv; + + +#ifdef _POSIX_CPUTIME + clock_gettime( CLOCK_PROCESS_CPUTIME_ID, &tv ); +#else + clock_gettime( CLOCK_REALTIME, &tv ); +#endif /* _POSIX_CPUTIME */ + + return 1E6 * (double)tv.tv_sec + 1E-3 * (double)tv.tv_nsec; + #else /* clock() accuracy has improved since glibc 2.18 */ return 1E6 * (double)clock() / (double)CLOCKS_PER_SEC; diff --git a/src/ftmemchk.c b/src/ftmemchk.c index dc3b3bf0719667856d1087fc0d1940bfd12699ab..3975b5600027aaf1f65131b2412a752910998c03 100644 --- a/src/ftmemchk.c +++ b/src/ftmemchk.c @@ -66,7 +66,7 @@ void record_my_block( void* base, long size ) { if ( block->base == base && block->size != 0 ) { - fprintf( stderr, "duplicate memory block at %08lx\n", (long)block->base ); + fprintf( stderr, "duplicate memory block at %p\n", block->base ); exit(1); } } diff --git a/src/ftpngout.c b/src/ftpngout.c index 137a1863f0eef2b34a8bf5d9388e51662def57c4..c0034253ada2e85c498bd21f72de4f1a4ff94457 100644 --- a/src/ftpngout.c +++ b/src/ftpngout.c @@ -147,7 +147,10 @@ #define WIN32_LEAN_AND_MEAN #include +/* Microsoft Visual C++ specific pragma */ +#ifdef _MSC_VER #pragma comment (lib,"Gdiplus.lib") +#endif /* Barebone definitions and opaque types to avoid GDI+ (C++) headers */