diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2021-08-31 16:52:54 +0200 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2021-08-31 16:52:54 +0200 |
| commit | 2b29e921db8800b015fe9f9d664e506c3e02b0e5 (patch) | |
| tree | 915771556f575f4881277e32e2a33a7d38a8c29d /FL/fl_casts.H | |
| parent | c91713fd889f4744924f41f8c13b87cec99ef645 (diff) | |
Fix MSVC compiler warnings in test/icon.cxx (#109)
Also:
- remove unnecessary 'size_t' conversions from FL/fl_casts.H
- add reverse conversions from integer types to 'void *'
Diffstat (limited to 'FL/fl_casts.H')
| -rw-r--r-- | FL/fl_casts.H | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/FL/fl_casts.H b/FL/fl_casts.H index 965f12eb1..1d0d881cd 100644 --- a/FL/fl_casts.H +++ b/FL/fl_casts.H @@ -17,22 +17,18 @@ #include <FL/platform_types.h> -inline char fl_char(void *v) { return (char)(fl_intptr_t)v; } -inline int fl_int(void *v) { return (int)(fl_intptr_t)v; } -inline long fl_long(void *v) { return (long)(fl_intptr_t)v; } +inline char fl_char(void *v) { return (char)(fl_intptr_t)v; } +inline int fl_int(void *v) { return (int)(fl_intptr_t)v; } +inline long fl_long(void *v) { return (long)(fl_intptr_t)v; } -inline unsigned char fl_uchar(void *v) { return (unsigned char)(fl_uintptr_t)v; } -inline unsigned int fl_uint(void *v) { return (unsigned int)(fl_uintptr_t)v; } -inline unsigned long fl_ulong(void *v) { return (unsigned long)(fl_uintptr_t)v; } +inline unsigned char fl_uchar(void *v) { return (unsigned char)(fl_uintptr_t)v; } +inline unsigned int fl_uint(void *v) { return (unsigned int)(fl_uintptr_t)v; } +inline unsigned long fl_ulong(void *v) { return (unsigned long)(fl_uintptr_t)v; } -#if 0 /* not necessary */ +// the following conversions can be used to silence MSVC warning C4312: +// 'type cast': conversion from '<type>' to 'void *' of greater size -inline char fl_char(size_t v) { return (char)v; } -inline int fl_int(size_t v) { return (int)v; } -inline long fl_long(size_t v) { return (long)v; } - -inline unsigned char fl_uchar(size_t v) { return (unsigned char)v; } -inline unsigned int fl_uint(size_t v) { return (unsigned int)v; } -inline unsigned long fl_ulong(size_t v) { return (unsigned long)v; } - -#endif /* not necessary */ +inline void *fl_voidptr(int v) { return (void *)(fl_intptr_t)v; } +inline void *fl_voidptr(unsigned int v) { return (void *)(fl_uintptr_t)v; } +inline void *fl_voidptr(long v) { return (void *)(fl_intptr_t)v; } +inline void *fl_voidptr(unsigned long v) { return (void *)(fl_uintptr_t)v; } |
