Commit 3f6e0e0c6b75c76def1cffe2967a1f5ace392007

Werner Lemberg 2013-06-07T18:10:40

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.

diff --git a/ChangeLog b/ChangeLog
index 8fddfb4..2472cfd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2013-06-07  Werner Lemberg  <wl@gnu.org>
 
+	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  <wl@gnu.org>
+
 	[cff] s/cf2_getGlyphWidth/cf2_getGlyphOutline/.
 
 	* src/cff/cf2font.c, src/cff/cf2font.h, src/cff/cf2ft.c: Do it.
diff --git a/include/freetype/internal/ftdebug.h b/include/freetype/internal/ftdebug.h
index 095da1d..1ee120f 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 724e1f0..4ac988b 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 00cd85e..12ad036 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 b1fd844..401fd64 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 c8cfb53..f267558 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 */