diff options
author | Werner Lemberg <wl@gnu.org> | 2021-11-13 08:53:19 +0100 |
---|---|---|
committer | Werner Lemberg <wl@gnu.org> | 2021-11-18 19:28:07 +0000 |
commit | 9079c5d91aa87bcae223fc933b9c0ebf346b7d64 (patch) | |
tree | f9d6107a8a02d44c7c134c3b3fc8ef2e9987575c /include/freetype/freetype.h | |
parent | 238245cd66e10025316463998a1fa20c15a065a8 (diff) | |
download | freetype2-9079c5d91aa87bcae223fc933b9c0ebf346b7d64.tar.gz |
Provide C++ versions for public macros with casts.
Many FreeType clients use C++. However `g++ -Wold-style-cast` warns for
macros with C-style casts even for system header files; this also affects
directories included with `-isystem`. While this could be seen as a problem
with g++, the problem is more a philosophical one: Over the time, C and C++
diverged more and more, and some features of C are no longer the 'right'
solution in C++.
* include/freetype/config/public-macros.h (FT_STATIC_CAST,
FT_REINTERPRET_CAST): New macros.
* include/freetype/freetype.h (FT_ENC_TAG, FT_LOAD_TARGET_,
FT_LOAD_TARGET_MODE): Use `FT_STATIC_CAST`.
Correctly handle negative 'signed char' input.
* include/freetype/ftimage.h (FT_IMAGE_TAG): Ditto.
* include/freetype/fttypes.h (FT_MAKE_TAG, FT_BOOL): Ditto.
* include/freetype/ftmodapi.h (FT_FACE_DRIVER_NAME): Use
`FT_REINTERPRET_CAST`.
* src/smooth/ftgrays.c (FT_STATIC_CAST)[STANDALONE_]: New macro.
[!STANDALONE]: Include `FT_CONFIG_CONFIG_H`.
Fixes #1116.
Diffstat (limited to 'include/freetype/freetype.h')
-rw-r--r-- | include/freetype/freetype.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h index b45718301..7da4eb687 100644 --- a/include/freetype/freetype.h +++ b/include/freetype/freetype.h @@ -616,11 +616,12 @@ FT_BEGIN_HEADER */ #ifndef FT_ENC_TAG -#define FT_ENC_TAG( value, a, b, c, d ) \ - value = ( ( (FT_UInt32)(a) << 24 ) | \ - ( (FT_UInt32)(b) << 16 ) | \ - ( (FT_UInt32)(c) << 8 ) | \ - (FT_UInt32)(d) ) + +#define FT_ENC_TAG( value, a, b, c, d ) \ + value = ( ( FT_STATIC_CAST( FT_Byte )(a) << 24 ) | \ + ( FT_STATIC_CAST( FT_Byte )(b) << 16 ) | \ + ( FT_STATIC_CAST( FT_Byte )(c) << 8 ) | \ + FT_STATIC_CAST( FT_Byte )(d) ) #endif /* FT_ENC_TAG */ @@ -3181,7 +3182,7 @@ FT_BEGIN_HEADER * necessary to empty the cache after a mode switch to avoid false hits. * */ -#define FT_LOAD_TARGET_( x ) ( (FT_Int32)( (x) & 15 ) << 16 ) +#define FT_LOAD_TARGET_( x ) ( FT_STATIC_CAST( FT_Int32 )( (x) & 15 ) << 16 ) #define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL ) #define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT ) @@ -3200,7 +3201,8 @@ FT_BEGIN_HEADER * @FT_LOAD_TARGET_XXX value. * */ -#define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) ) +#define FT_LOAD_TARGET_MODE( x ) \ + FT_STATIC_CAST( FT_Render_Mode )( ( (x) >> 16 ) & 15 ) /************************************************************************** |