From 3f6e0e0c6b75c76def1cffe2967a1f5ace392007 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Fri, 7 Jun 2013 18:10:40 +0200 Subject: [PATCH] Add and improve pragmas for MSVC compiler. * include/freetype/internal/ftdebug.h: Remove pragmas. * include/freetype/internal/ftserv.h: Use push and pop for pragmas. * include/freetype/internal/ftvalid.h: Handle warning C4324. * src/base/ftobjs.c: Use push and pop for pragmas. * src/gzip/ftgzip.c: Handle warning C4244. --- ChangeLog | 10 ++++++++++ include/freetype/internal/ftdebug.h | 9 --------- include/freetype/internal/ftserv.h | 14 +++++++++----- include/freetype/internal/ftvalid.h | 15 +++++++++++++-- src/base/ftobjs.c | 3 ++- src/gzip/ftgzip.c | 13 +++++++++++++ 6 files changed, 47 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8fddfb4aa..2472cfd3e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2013-06-07 Werner Lemberg + + Add and improve pragmas for MSVC compiler. + + * include/freetype/internal/ftdebug.h: Remove pragmas. + * include/freetype/internal/ftserv.h: Use push and pop for pragmas. + * include/freetype/internal/ftvalid.h: Handle warning C4324. + * src/base/ftobjs.c: Use push and pop for pragmas. + * src/gzip/ftgzip.c: Handle warning C4244. + 2013-06-07 Werner Lemberg [cff] s/cf2_getGlyphWidth/cf2_getGlyphOutline/. diff --git a/include/freetype/internal/ftdebug.h b/include/freetype/internal/ftdebug.h index 095da1d90..1ee120f5e 100644 --- a/include/freetype/internal/ftdebug.h +++ b/include/freetype/internal/ftdebug.h @@ -248,15 +248,6 @@ FT_BEGIN_HEADER ft_debug_init( void ); -#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ - - /* We disable the warning `conditional expression is constant' here */ - /* in order to compile cleanly with the maximum level of warnings. */ -#pragma warning( disable : 4127 ) - -#endif /* _MSC_VER */ - - FT_END_HEADER #endif /* __FTDEBUG_H__ */ diff --git a/include/freetype/internal/ftserv.h b/include/freetype/internal/ftserv.h index 724e1f0b4..4ac988bd2 100644 --- a/include/freetype/internal/ftserv.h +++ b/include/freetype/internal/ftserv.h @@ -34,12 +34,12 @@ FT_BEGIN_HEADER -#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ - - /* we disable the warning `conditional expression is constant' here */ - /* in order to compile cleanly with the maximum level of warnings */ +#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ + /* We disable the warning `conditional expression is */ + /* constant' in order to compile cleanly with the maximum */ + /* level of warnings. */ +#pragma warning( push ) #pragma warning( disable : 4127 ) - #endif /* _MSC_VER */ /* @@ -763,6 +763,10 @@ FT_BEGIN_HEADER /* */ +#if defined( _MSC_VER ) +#pragma warning( pop ) +#endif + FT_END_HEADER #endif /* __FTSERV_H__ */ diff --git a/include/freetype/internal/ftvalid.h b/include/freetype/internal/ftvalid.h index 00cd85e7b..12ad03685 100644 --- a/include/freetype/internal/ftvalid.h +++ b/include/freetype/internal/ftvalid.h @@ -4,7 +4,7 @@ /* */ /* FreeType validation support (specification). */ /* */ -/* Copyright 2004 by */ +/* Copyright 2004, 2013 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -76,6 +76,14 @@ FT_BEGIN_HEADER } FT_ValidationLevel; +#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ + /* We disable the warning `structure was padded due to */ + /* __declspec(align())' in order to compile cleanly with */ + /* the maximum level of warnings. */ +#pragma warning( push ) +#pragma warning( disable : 4324 ) +#endif /* _MSC_VER */ + /* validator structure */ typedef struct FT_ValidatorRec_ { @@ -88,8 +96,11 @@ FT_BEGIN_HEADER } FT_ValidatorRec; +#if defined( _MSC_VER ) +#pragma warning( pop ) +#endif -#define FT_VALIDATOR( x ) ((FT_Validator)( x )) +#define FT_VALIDATOR( x ) ( (FT_Validator)( x ) ) FT_BASE( void ) diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index b1fd844e0..401fd6482 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -51,6 +51,7 @@ /* possible loss of data' in order to compile cleanly with */ /* the maximum level of warnings: `md5.c' is non-FreeType */ /* code, and it gets used during development builds only. */ +#pragma warning( push ) #pragma warning( disable : 4244 ) #endif /* _MSC_VER */ @@ -60,7 +61,7 @@ #undef free #if defined( _MSC_VER ) -#pragma warning( default : 4244 ) +#pragma warning( pop ) #endif #endif /* FT_DEBUG_LEVEL_TRACE */ diff --git a/src/gzip/ftgzip.c b/src/gzip/ftgzip.c index c8cfb5394..f26755834 100644 --- a/src/gzip/ftgzip.c +++ b/src/gzip/ftgzip.c @@ -68,6 +68,15 @@ #undef SLOW #define SLOW 1 /* we can't use asm-optimized sources here! */ +#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ + /* We disable the warning `conversion from XXX to YYY, */ + /* possible loss of data' in order to compile cleanly with */ + /* the maximum level of warnings: zlib is non-FreeType */ + /* code. */ +#pragma warning( push ) +#pragma warning( disable : 4244 ) +#endif /* _MSC_VER */ + /* Urgh. `inflate_mask' must not be declared twice -- C++ doesn't like this. We temporarily disable it and load all necessary header files. */ #define NO_INFLATE_MASK @@ -87,6 +96,10 @@ #include "inflate.c" #include "adler32.c" +#if defined( _MSC_VER ) +#pragma warning( pop ) +#endif + #endif /* !FT_CONFIG_OPTION_SYSTEM_ZLIB */