diff --git a/MagickCore/MagickCore.h b/MagickCore/MagickCore.h
index b1eef02..6670b8f 100644
--- a/MagickCore/MagickCore.h
+++ b/MagickCore/MagickCore.h
@@ -57,6 +57,7 @@
 #include <stdlib.h>
 #include <math.h>
 #include <sys/types.h>
+#include <time.h>
 
 #if defined(WIN32) || defined(WIN64)
 #  define MAGICKCORE_WINDOWS_SUPPORT
diff --git a/MagickCore/animate-private.h b/MagickCore/animate-private.h
index c295c5d..01e5357 100644
--- a/MagickCore/animate-private.h
+++ b/MagickCore/animate-private.h
@@ -18,13 +18,15 @@
 #ifndef _MAGICKCORE_ANIMATE_PRIVATE_H
 #define _MAGICKCORE_ANIMATE_PRIVATE_H
 
+#if defined(MAGICKCORE_X11_DELEGATE)
+#include "MagickCore/xwindow-private.h"
+#endif
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
 #if defined(MAGICKCORE_X11_DELEGATE)
-#include "MagickCore/xwindow-private.h"
-
 extern MagickExport Image
   *XAnimateImages(Display *,XResourceInfo *,char **,const int,Image *,
     ExceptionInfo *);
diff --git a/MagickCore/annotate.h b/MagickCore/annotate.h
index 8a7cde5..e42d689 100644
--- a/MagickCore/annotate.h
+++ b/MagickCore/annotate.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_ANNOTATE_H
 #define _MAGICKCORE_ANNOTATE_H
 
+#include "MagickCore/draw.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/draw.h"
-
 extern MagickExport MagickBooleanType
   AnnotateImage(Image *,const DrawInfo *,ExceptionInfo *),
   GetMultilineTypeMetrics(Image *,const DrawInfo *,TypeMetric *,
diff --git a/MagickCore/attribute.h b/MagickCore/attribute.h
index 27916c9..ffbe446 100644
--- a/MagickCore/attribute.h
+++ b/MagickCore/attribute.h
@@ -18,13 +18,13 @@
 #ifndef _MAGICKCORE_ATTRIBUTE_H
 #define _MAGICKCORE_ATTRIBUTE_H
 
+#include "MagickCore/image.h"
+#include "MagickCore/exception.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/image.h"
-#include "MagickCore/exception.h"
-
 extern MagickExport ImageType
   GetImageType(const Image *,ExceptionInfo *);
 
diff --git a/MagickCore/blob-private.h b/MagickCore/blob-private.h
index 4000fdc..3174637 100644
--- a/MagickCore/blob-private.h
+++ b/MagickCore/blob-private.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_BLOB_PRIVATE_H
 #define _MAGICKCORE_BLOB_PRIVATE_H
 
+#include "MagickCore/nt-feature.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/nt-feature.h"
-
 #define MagickMinBlobExtent  32767L
 #if defined(MAGICKCORE_HAVE_FSEEKO)
 # define fseek  fseeko
diff --git a/MagickCore/blob.h b/MagickCore/blob.h
index 6304d4f..03c06cd 100644
--- a/MagickCore/blob.h
+++ b/MagickCore/blob.h
@@ -18,13 +18,13 @@
 #ifndef _MAGICKCORE_BLOB_H
 #define _MAGICKCORE_BLOB_H
 
+#include "MagickCore/image.h"
+#include "MagickCore/stream.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/image.h"
-#include "MagickCore/stream.h"
-
 #define MagickMaxBufferExtent  (32*8192-2)
 
 typedef enum
diff --git a/MagickCore/cache-private.h b/MagickCore/cache-private.h
index 3be96a9..e27142a 100644
--- a/MagickCore/cache-private.h
+++ b/MagickCore/cache-private.h
@@ -18,11 +18,6 @@
 #ifndef _MAGICKCORE_CACHE_PRIVATE_H
 #define _MAGICKCORE_CACHE_PRIVATE_H
 
-#if defined(__cplusplus) || defined(c_plusplus)
-extern "C" {
-#endif
-
-#include <time.h>
 #include "MagickCore/cache.h"
 #include "MagickCore/distribute-cache.h"
 #include "MagickCore/pixel.h"
@@ -30,6 +25,10 @@
 #include "MagickCore/thread-private.h"
 #include "MagickCore/semaphore.h"
 
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 typedef void
   *Cache;
 
diff --git a/MagickCore/cache-view.h b/MagickCore/cache-view.h
index b943f87..0e74969 100644
--- a/MagickCore/cache-view.h
+++ b/MagickCore/cache-view.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_CACHE_VIEW_H
 #define _MAGICKCORE_CACHE_VIEW_H
 
+#include "MagickCore/pixel.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/pixel.h"
-
 typedef enum
 {
   UndefinedVirtualPixelMethod,
diff --git a/MagickCore/cache.h b/MagickCore/cache.h
index 87b0460..e606e6d 100644
--- a/MagickCore/cache.h
+++ b/MagickCore/cache.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_CACHE_H
 #define _MAGICKCORE_CACHE_H
 
+#include "MagickCore/blob.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/blob.h"
-
 typedef enum
 {
   UndefinedCache,
diff --git a/MagickCore/channel.c b/MagickCore/channel.c
index 4408069..2430bf1 100644
--- a/MagickCore/channel.c
+++ b/MagickCore/channel.c
@@ -197,6 +197,10 @@
   return(status);
 }
 
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 MagickExport Image *ChannelFxImage(const Image *image,const char *expression,
   ExceptionInfo *exception)
 {
@@ -441,6 +445,10 @@
     }
   return(GetFirstImageInList(destination_image));
 }
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
 
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -472,6 +480,10 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 MagickExport Image *CombineImages(const Image *image,
   const ColorspaceType colorspace,ExceptionInfo *exception)
 {
@@ -594,6 +606,10 @@
     combine_image=DestroyImage(combine_image);
   return(combine_image);
 }
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
 
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -656,6 +672,10 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 MagickExport Image *SeparateImage(const Image *image,
   const ChannelType channel_type,ExceptionInfo *exception)
 {
@@ -776,6 +796,10 @@
     separate_image=DestroyImage(separate_image);
   return(separate_image);
 }
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
 
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -802,6 +826,10 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 MagickExport Image *SeparateImages(const Image *image,ExceptionInfo *exception)
 {
   Image
@@ -831,6 +859,10 @@
     images=SeparateImage(image,UndefinedChannel,exception);
   return(images);
 }
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
 
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -926,6 +958,10 @@
   }
 }
 
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 MagickExport MagickBooleanType SetImageAlphaChannel(Image *image,
   const AlphaChannelOption alpha_type,ExceptionInfo *exception)
 {
@@ -1095,3 +1131,7 @@
     return(status);
   return(SyncImagePixelCache(image,exception));
 }
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
diff --git a/MagickCore/channel.h b/MagickCore/channel.h
index b1b70ad..157dc23 100644
--- a/MagickCore/channel.h
+++ b/MagickCore/channel.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_CHANNEL_H
 #define _MAGICKCORE_CHANNEL_H
 
+#include <MagickCore/image.h>
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include <MagickCore/image.h>
-
 extern MagickExport Image
   *ChannelFxImage(const Image *,const char *,ExceptionInfo *),
   *CombineImages(const Image *,const ColorspaceType,ExceptionInfo *),
diff --git a/MagickCore/color-private.h b/MagickCore/color-private.h
index 349cd0e..3b3ea0f 100644
--- a/MagickCore/color-private.h
+++ b/MagickCore/color-private.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_COLOR_PRIVATE_H
 #define _MAGICKCORE_COLOR_PRIVATE_H
 
+#include "MagickCore/image.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/image.h"
-
 extern MagickPrivate MagickBooleanType
   ColorComponentGenesis(void);
 
diff --git a/MagickCore/color.h b/MagickCore/color.h
index f487e14..f477b02 100644
--- a/MagickCore/color.h
+++ b/MagickCore/color.h
@@ -18,13 +18,13 @@
 #ifndef _MAGICKCORE_COLOR_H
 #define _MAGICKCORE_COLOR_H
 
+#include "MagickCore/pixel.h"
+#include "MagickCore/exception.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/pixel.h"
-#include "MagickCore/exception.h"
-
 typedef enum
 {
   UndefinedCompliance,
diff --git a/MagickCore/colormap-private.h b/MagickCore/colormap-private.h
index b7d4e36..dc7dd13 100644
--- a/MagickCore/colormap-private.h
+++ b/MagickCore/colormap-private.h
@@ -18,14 +18,14 @@
 #ifndef _MAGICKCORE_COLORMAP_PRIVATE_H
 #define _MAGICKCORE_COLORMAP_PRIVATE_H
 
-#if defined(__cplusplus) || defined(c_plusplus)
-extern "C" {
-#endif
-
 #include "MagickCore/image.h"
 #include "MagickCore/color.h"
 #include "MagickCore/exception-private.h"
 
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 static inline Quantum ConstrainColormapIndex(Image *image,const size_t index,
   ExceptionInfo *exception)
 {
diff --git a/MagickCore/colorspace-private.h b/MagickCore/colorspace-private.h
index ecebdfc..7dfb8fd 100644
--- a/MagickCore/colorspace-private.h
+++ b/MagickCore/colorspace-private.h
@@ -18,15 +18,15 @@
 #ifndef _MAGICKCORE_COLORSPACE_PRIVATE_H
 #define _MAGICKCORE_COLORSPACE_PRIVATE_H
 
-#if defined(__cplusplus) || defined(c_plusplus)
-extern "C" {
-#endif
-
 #include "MagickCore/image.h"
 #include "MagickCore/image-private.h"
 #include "MagickCore/pixel.h"
 #include "MagickCore/pixel-accessor.h"
 
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 static inline void ConvertRGBToCMYK(PixelInfo *pixel)
 {
   MagickRealType
diff --git a/MagickCore/compare.h b/MagickCore/compare.h
index 3eba290..50429da 100644
--- a/MagickCore/compare.h
+++ b/MagickCore/compare.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_COMPARE_H
 #define _MAGICKCORE_COMPARE_H
 
+#include "MagickCore/image.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/image.h"
-
 typedef enum
 {
   UndefinedErrorMetric,
diff --git a/MagickCore/composite-private.h b/MagickCore/composite-private.h
index 37ae0bd..415f623 100644
--- a/MagickCore/composite-private.h
+++ b/MagickCore/composite-private.h
@@ -18,13 +18,6 @@
 #ifndef _MAGICKCORE_COMPOSITE_PRIVATE_H
 #define _MAGICKCORE_COMPOSITE_PRIVATE_H
 
-#if defined(__cplusplus) || defined(c_plusplus)
-extern "C" {
-#endif
-
-/*
-  ImageMagick Alpha Composite Inline Methods (special export)
-*/
 
 #include "MagickCore/color.h"
 #include "MagickCore/image.h"
@@ -32,6 +25,13 @@
 #include "MagickCore/pixel-accessor.h"
 #include "MagickCore/pixel-private.h"
 
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+/*
+  ImageMagick Alpha Composite Inline Methods (special export)
+*/
 static inline double MagickOver_(const double p,
   const double alpha,const double q,const double beta)
 {
diff --git a/MagickCore/configure.h b/MagickCore/configure.h
index d950ddc..29f1dba 100644
--- a/MagickCore/configure.h
+++ b/MagickCore/configure.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_CONFIGURE_H
 #define _MAGICKCORE_CONFIGURE_H
 
+#include "MagickCore/hashmap.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/hashmap.h"
-
 typedef struct _ConfigureInfo
 {
   char
diff --git a/MagickCore/constitute.h b/MagickCore/constitute.h
index a45e622..a77370a 100644
--- a/MagickCore/constitute.h
+++ b/MagickCore/constitute.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_CONSTITUTE_H
 #define _MAGICKCORE_CONSTITUTE_H
 
+#include "MagickCore/pixel.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/pixel.h"
-
 extern MagickExport Image
   *ConstituteImage(const size_t,const size_t,const char *,const StorageType,
     const void *,ExceptionInfo *),
diff --git a/MagickCore/decorate.h b/MagickCore/decorate.h
index c9913b7..cce4834 100644
--- a/MagickCore/decorate.h
+++ b/MagickCore/decorate.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_DECORATE_H
 #define _MAGICKCORE_DECORATE_H
 
+#include "MagickCore/image.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/image.h"
-
 typedef struct _FrameInfo
 {
   size_t
diff --git a/MagickCore/delegate-private.h b/MagickCore/delegate-private.h
index ccdb59c..8f6757f 100644
--- a/MagickCore/delegate-private.h
+++ b/MagickCore/delegate-private.h
@@ -18,15 +18,15 @@
 #ifndef _MAGICKCORE_DELEGATE_PRIVATE_H
 #define _MAGICKCORE_DELEGATE_PRIVATE_H
 
-#if defined(__cplusplus) || defined(c_plusplus)
-extern "C" {
-#endif
-
 #if defined(MAGICKCORE_GS_DELEGATE)
 #include "ghostscript/iapi.h"
 #include "ghostscript/ierrors.h"
 #endif
 
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 #ifndef gs_main_instance_DEFINED
 # define gs_main_instance_DEFINED
 typedef struct gs_main_instance_s
diff --git a/MagickCore/display-private.h b/MagickCore/display-private.h
index 8d0581f..c91e4ae 100644
--- a/MagickCore/display-private.h
+++ b/MagickCore/display-private.h
@@ -18,13 +18,15 @@
 #ifndef _MAGICKCORE_DISPLAY_PRIVATE_H
 #define _MAGICKCORE_DISPLAY_PRIVATE_H
 
+#if defined(MAGICKCORE_X11_DELEGATE)
+#include "MagickCore/xwindow-private.h"
+#endif
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
 #if defined(MAGICKCORE_X11_DELEGATE)
-#include "MagickCore/xwindow-private.h"
-
 extern MagickExport Image
   *XDisplayImage(Display *,XResourceInfo *,char **,int,Image **,size_t *,
     ExceptionInfo *);
diff --git a/MagickCore/distribute-cache-private.h b/MagickCore/distribute-cache-private.h
index 6b6f5ff..86381a5 100644
--- a/MagickCore/distribute-cache-private.h
+++ b/MagickCore/distribute-cache-private.h
@@ -18,13 +18,13 @@
 #ifndef _MAGICKCORE_DISTRIBUTE_CACHE_PRIVATE_H
 #define _MAGICKCORE_DISTRIBUTE_CACHE_PRIVATE_H
 
+#include "MagickCore/geometry.h"
+#include "MagickCore/exception.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/geometry.h"
-#include "MagickCore/exception.h"
-
 typedef struct _DistributeCacheInfo
 {
   int
diff --git a/MagickCore/distribute-cache.h b/MagickCore/distribute-cache.h
index 4bfb362..68a5e7a 100644
--- a/MagickCore/distribute-cache.h
+++ b/MagickCore/distribute-cache.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_DISTRIBUTE_CACHE_H
 #define _MAGICKCORE_DISTRIBUTE_CACHE_H
 
+#include "MagickCore/exception.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/exception.h"
-
 extern MagickExport void
   DistributePixelCacheServer(const int,ExceptionInfo *);
 
diff --git a/MagickCore/draw-private.h b/MagickCore/draw-private.h
index 9216fde..1beae0d 100644
--- a/MagickCore/draw-private.h
+++ b/MagickCore/draw-private.h
@@ -18,14 +18,14 @@
 #ifndef _MAGICKCORE_DRAW_PRIVATE_H
 #define _MAGICKCORE_DRAW_PRIVATE_H
 
-#if defined(__cplusplus) || defined(c_plusplus)
-extern "C" {
-#endif
-
 #include "MagickCore/cache.h"
 #include "MagickCore/image.h"
 #include "MagickCore/memory_.h"
 
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 static inline MagickBooleanType GetFillColor(const DrawInfo *draw_info,
   const ssize_t x,const ssize_t y,PixelInfo *fill,ExceptionInfo *exception)
 {
diff --git a/MagickCore/draw.h b/MagickCore/draw.h
index aaf679e..0fc675f 100644
--- a/MagickCore/draw.h
+++ b/MagickCore/draw.h
@@ -18,15 +18,15 @@
 #ifndef _MAGICKCORE_DRAW_H
 #define _MAGICKCORE_DRAW_H
 
-#if defined(__cplusplus) || defined(c_plusplus)
-extern "C" {
-#endif
-
 #include "MagickCore/geometry.h"
 #include "MagickCore/image.h"
 #include "MagickCore/pixel.h"
 #include "MagickCore/type.h"
 
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 typedef enum
 {
   UndefinedAlign,
diff --git a/MagickCore/effect.h b/MagickCore/effect.h
index 597e70f..626fca4 100644
--- a/MagickCore/effect.h
+++ b/MagickCore/effect.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_EFFECT_H
 #define _MAGICKCORE_EFFECT_H
 
+#include "MagickCore/morphology.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/morphology.h"
-
 typedef enum
 {
   UndefinedPreview,
diff --git a/MagickCore/enhance.h b/MagickCore/enhance.h
index 1ba93fc..3b04f97 100644
--- a/MagickCore/enhance.h
+++ b/MagickCore/enhance.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_ENHANCE_H
 #define _MAGICKCORE_ENHANCE_H
 
+#include "MagickCore/pixel.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/pixel.h"
-
 extern MagickExport MagickBooleanType
   AutoGammaImage(Image *,ExceptionInfo *),
   AutoLevelImage(Image *,ExceptionInfo *),
diff --git a/MagickCore/exception-private.h b/MagickCore/exception-private.h
index 66802ec..821feb4 100644
--- a/MagickCore/exception-private.h
+++ b/MagickCore/exception-private.h
@@ -18,14 +18,14 @@
 #ifndef _MAGICKCORE_EXCEPTION_PRIVATE_H
 #define _MAGICKCORE_EXCEPTION_PRIVATE_H
 
-#if defined(__cplusplus) || defined(c_plusplus)
-extern "C" {
-#endif
-
 #include "MagickCore/log.h"
 #include "MagickCore/magick.h"
 #include "MagickCore/string_.h"
 
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 #define ThrowBinaryException(severity,tag,context) \
 { \
   if (image != (Image *) NULL) \
diff --git a/MagickCore/exception.h b/MagickCore/exception.h
index 7930a62..a1b1b5a 100644
--- a/MagickCore/exception.h
+++ b/MagickCore/exception.h
@@ -18,13 +18,12 @@
 #ifndef _MAGICKCORE_EXCEPTION_H
 #define _MAGICKCORE_EXCEPTION_H
 
+#include "MagickCore/semaphore.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include <stdarg.h>
-#include "MagickCore/semaphore.h"
-
 typedef enum
 {
   UndefinedException,
diff --git a/MagickCore/fx.h b/MagickCore/fx.h
index 74c5071..e8fde7a 100644
--- a/MagickCore/fx.h
+++ b/MagickCore/fx.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_FX_H
 #define _MAGICKCORE_FX_H
 
+#include "MagickCore/draw.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/draw.h"
-
 typedef enum
 {
   UndefinedNoise,
diff --git a/MagickCore/gem-private.h b/MagickCore/gem-private.h
index e255ee4..f3ca0dc 100644
--- a/MagickCore/gem-private.h
+++ b/MagickCore/gem-private.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_GEM_PRIVATE_H
 #define _MAGICKCORE_GEM_PRIVATE_H
 
+#include "MagickCore/pixel-private.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/pixel-private.h"
-
 #define D65X  0.950456
 #define D65Y  1.0
 #define D65Z  1.088754
diff --git a/MagickCore/gem.h b/MagickCore/gem.h
index f875ddf..bb4c026 100644
--- a/MagickCore/gem.h
+++ b/MagickCore/gem.h
@@ -18,13 +18,13 @@
 #ifndef _MAGICKCORE_GEM_H
 #define _MAGICKCORE_GEM_H
 
+#include "MagickCore/fx.h"
+#include "MagickCore/random_.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/fx.h"
-#include "MagickCore/random_.h"
-
 extern MagickExport double
   ExpandAffine(const AffineMatrix *);
 
diff --git a/MagickCore/image.h b/MagickCore/image.h
index 5447351..18f938c 100644
--- a/MagickCore/image.h
+++ b/MagickCore/image.h
@@ -18,13 +18,13 @@
 #ifndef _MAGICKCORE_IMAGE_H
 #define _MAGICKCORE_IMAGE_H
 
+#include "MagickCore/color.h"
+#include "MagickCore/pixel.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/color.h"
-#include "MagickCore/pixel.h"
-
 #define OpaqueAlpha  ((Quantum) QuantumRange)
 #define TransparentAlpha  ((Quantum) 0)
 
diff --git a/MagickCore/layer.h b/MagickCore/layer.h
index 386d886..19dd7e4 100644
--- a/MagickCore/layer.h
+++ b/MagickCore/layer.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_LAYER_H
 #define _MAGICKCORE_LAYER_H
 
+#include "MagickCore/composite.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/composite.h"
-
 typedef enum
 {
   UnrecognizedDispose,
diff --git a/MagickCore/locale_.h b/MagickCore/locale_.h
index 4efaa2d..cad356b 100644
--- a/MagickCore/locale_.h
+++ b/MagickCore/locale_.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_LOCALE_H
 #define _MAGICKCORE_LOCALE_H
 
+#include "MagickCore/hashmap.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/hashmap.h"
-
 typedef struct _LocaleInfo
 {
   char
diff --git a/MagickCore/log-private.h b/MagickCore/log-private.h
index 7043157..2ac9d86 100644
--- a/MagickCore/log-private.h
+++ b/MagickCore/log-private.h
@@ -18,13 +18,12 @@
 #ifndef _MAGICKCORE_LOG_PRIVATE_H
 #define _MAGICKCORE_LOG_PRIVATE_H
 
+#include "MagickCore/exception.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include <stdarg.h>
-#include "MagickCore/exception.h"
-
 extern MagickPrivate MagickBooleanType
   LogComponentGenesis(void);
 
diff --git a/MagickCore/log.h b/MagickCore/log.h
index e74795f..d58715d 100644
--- a/MagickCore/log.h
+++ b/MagickCore/log.h
@@ -18,13 +18,12 @@
 #ifndef _MAGICKCORE_LOG_H
 #define _MAGICKCORE_LOG_H
 
+#include "MagickCore/exception.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include <stdarg.h>
-#include "MagickCore/exception.h"
-
 #if !defined(GetMagickModule)
 # define GetMagickModule()  __FILE__,__func__,(unsigned long) __LINE__
 #endif
diff --git a/MagickCore/mac.h b/MagickCore/mac.h
index ed9c964..19e1afe 100644
--- a/MagickCore/mac.h
+++ b/MagickCore/mac.h
@@ -18,15 +18,15 @@
 #ifndef _MAGICKCORE_MAC_H
 #define _MAGICKCORE_MAC_H
 
-#if defined(__cplusplus) || defined(c_plusplus)
-extern "C" {
-#endif
-
 #include <locale.h>
 #include <Errors.h>
 #include <Files.h>
 #include <errno.h>
 
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 #if defined(_MAGICKCORE_POSIX_SUPPORT_VERSION)
 # include <dirent.h>
 # if !defined(DISABLE_SIOUX)
diff --git a/MagickCore/magick-type.h b/MagickCore/magick-type.h
index 08155af..db3dc9b 100644
--- a/MagickCore/magick-type.h
+++ b/MagickCore/magick-type.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_MAGICK_TYPE_H
 #define _MAGICKCORE_MAGICK_TYPE_H
 
+#include "MagickCore/magick-config.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/magick-config.h"
-
 #if !defined(MAGICKCORE_QUANTUM_DEPTH)
 #define MAGICKCORE_QUANTUM_DEPTH  16
 #endif
diff --git a/MagickCore/module.h b/MagickCore/module.h
index 6e27214..88e660e 100644
--- a/MagickCore/module.h
+++ b/MagickCore/module.h
@@ -18,13 +18,12 @@
 #ifndef _MAGICKCORE_MODULE_H
 #define _MAGICKCORE_MODULE_H
 
+#include "MagickCore/version.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include <time.h>
-#include "MagickCore/version.h"
-
 #define MagickImageCoderSignature  ((size_t) \
   (((MagickLibVersion) << 8) | MAGICKCORE_QUANTUM_DEPTH))
 #define MagickImageFilterSignature  ((size_t) \
diff --git a/MagickCore/monitor-private.h b/MagickCore/monitor-private.h
index ac17205..c94d8e9 100644
--- a/MagickCore/monitor-private.h
+++ b/MagickCore/monitor-private.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICK_MONITOR_PRIVATE_H
 #define _MAGICK_MONITOR_PRIVATE_H
 
+#include "MagickCore/image.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/image.h"
-
 static inline MagickBooleanType SetImageProgress(const Image *image,
   const char *tag,const MagickOffsetType offset,const MagickSizeType extent)
 {
diff --git a/MagickCore/morphology-private.h b/MagickCore/morphology-private.h
index 8505184..5ea762d 100644
--- a/MagickCore/morphology-private.h
+++ b/MagickCore/morphology-private.h
@@ -18,16 +18,12 @@
 #ifndef _MAGICK_MORPHOLOGY_PRIVATE_H
 #define _MAGICK_MORPHOLOGY_PRIVATE_H
 
+#include "MagickCore/morphology.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#if defined(__cplusplus) || defined(c_plusplus)
-}
-#endif
-
-#include "MagickCore/morphology.h"
-
 extern MagickPrivate Image
   *MorphologyApply(const Image *,const MorphologyMethod,const ssize_t,
     const KernelInfo *,const CompositeOperator,const double,ExceptionInfo *);
@@ -36,4 +32,8 @@
   ShowKernelInfo(const KernelInfo *),
   ZeroKernelNans(KernelInfo *);
 
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
 #endif
diff --git a/MagickCore/morphology.h b/MagickCore/morphology.h
index 205717c..25e0f17 100644
--- a/MagickCore/morphology.h
+++ b/MagickCore/morphology.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_MORPHOLOGY_H
 #define _MAGICKCORE_MORPHOLOGY_H
 
+#include "MagickCore/geometry.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/geometry.h"
-
 typedef enum
 {
   UndefinedKernel,    /* equivalent to UnityKernel */
diff --git a/MagickCore/nt-base-private.h b/MagickCore/nt-base-private.h
index 9acc1a8..119ac78 100644
--- a/MagickCore/nt-base-private.h
+++ b/MagickCore/nt-base-private.h
@@ -18,17 +18,17 @@
 #ifndef _MAGICKCORE_NT_BASE_PRIVATE_H
 #define _MAGICKCORE_NT_BASE_PRIVATE_H
 
+#include "MagickCore/delegate.h"
+#include "MagickCore/delegate-private.h"
+#include "MagickCore/exception.h"
+#include "MagickCore/splay-tree.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
 
-#include "MagickCore/delegate.h"
-#include "MagickCore/delegate-private.h"
-#include "MagickCore/exception.h"
-#include "MagickCore/splay-tree.h"
-
 #define WIN32_LEAN_AND_MEAN
 #define VC_EXTRALEAN
 #define _CRT_SECURE_NO_DEPRECATE  1
diff --git a/MagickCore/nt-base.h b/MagickCore/nt-base.h
index 3928f17..041ebe0 100644
--- a/MagickCore/nt-base.h
+++ b/MagickCore/nt-base.h
@@ -18,13 +18,13 @@
 #ifndef _MAGICKCORE_NT_BASE_H
 #define _MAGICKCORE_NT_BASE_H
 
+#include "MagickCore/exception.h"
+#include "MagickCore/geometry.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/exception.h"
-#include "MagickCore/geometry.h"
-
 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
 typedef struct _GhostInfo
   GhostInfo_;
diff --git a/MagickCore/nt-feature.h b/MagickCore/nt-feature.h
index 81b9d83..40cb6db 100644
--- a/MagickCore/nt-feature.h
+++ b/MagickCore/nt-feature.h
@@ -18,14 +18,14 @@
 #ifndef _MAGICKCORE_NT_FEATURE_H
 #define _MAGICKCORE_NT_FEATURE_H
 
-#if defined(__cplusplus) || defined(c_plusplus)
-extern "C" {
-#endif
-
 #include "MagickCore/exception.h"
 #include "MagickCore/geometry.h"
 #include "MagickCore/splay-tree.h"
 
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 extern MagickExport void
   *CropImageToHBITMAP(Image *,const RectangleInfo *,ExceptionInfo *),
   *ImageToHBITMAP(Image *,ExceptionInfo *);
diff --git a/MagickCore/opencl-private.h b/MagickCore/opencl-private.h
index b585976..7264366 100644
--- a/MagickCore/opencl-private.h
+++ b/MagickCore/opencl-private.h
@@ -1,26 +1,23 @@
 /*
-Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization
-dedicated to making software imaging solutions freely available.
+  Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization
+  dedicated to making software imaging solutions freely available.
 
-You may not use this file except in compliance with the License.
-obtain a copy of the License at
+  You may not use this file except in compliance with the License.
+  obtain a copy of the License at
 
-http://www.imagemagick.org/script/license.php
+  http://www.imagemagick.org/script/license.php
 
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
 
-MagickCore OpenCL private methods.
+  MagickCore OpenCL private methods.
 */
 #ifndef _MAGICKCORE_OPENCL_PRIVATE_H
 #define _MAGICKCORE_OPENCL_PRIVATE_H
 
-/*
-Include declarations.
-*/
 #include "MagickCore/studio.h"
 #include "MagickCore/opencl.h"
 
diff --git a/MagickCore/paint.h b/MagickCore/paint.h
index bd3e9e9..aa718d3 100644
--- a/MagickCore/paint.h
+++ b/MagickCore/paint.h
@@ -18,13 +18,13 @@
 #ifndef _MAGICKCORE_PAINT_H
 #define _MAGICKCORE_PAINT_H
 
+#include "MagickCore/color.h"
+#include "MagickCore/draw.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/color.h"
-#include "MagickCore/draw.h"
-
 extern MagickExport Image
   *OilPaintImage(const Image *,const double,const double,ExceptionInfo *);
 
diff --git a/MagickCore/pixel-accessor.h b/MagickCore/pixel-accessor.h
index c35c5b3..d605408 100644
--- a/MagickCore/pixel-accessor.h
+++ b/MagickCore/pixel-accessor.h
@@ -18,11 +18,6 @@
 #ifndef _MAGICKCORE_PIXEL_ACCESSOR_H
 #define _MAGICKCORE_PIXEL_ACCESSOR_H
 
-#if defined(__cplusplus) || defined(c_plusplus)
-extern "C" {
-#endif
-
-#include <math.h>
 #include "MagickCore/cache.h"
 #include "MagickCore/cache-view.h"
 #include "MagickCore/color.h"
@@ -30,6 +25,10 @@
 #include "MagickCore/gem.h"
 #include "MagickCore/image.h"
 
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 #undef index
 
 static inline Quantum GetPixela(const Image *restrict image,
diff --git a/MagickCore/pixel.h b/MagickCore/pixel.h
index 216b792..d607a30 100644
--- a/MagickCore/pixel.h
+++ b/MagickCore/pixel.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_PIXEL_H
 #define _MAGICKCORE_PIXEL_H
 
+#include "MagickCore/colorspace.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/colorspace.h"
-
 #define MaxPixelChannels  32
 #undef index
 
diff --git a/MagickCore/policy.h b/MagickCore/policy.h
index 8eadbdf..2ea48b2 100644
--- a/MagickCore/policy.h
+++ b/MagickCore/policy.h
@@ -18,13 +18,13 @@
 #ifndef _MAGICKCORE_POLICY_H
 #define _MAGICKCORE_POLICY_H
 
+#include "MagickCore/pixel.h"
+#include "MagickCore/exception.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/pixel.h"
-#include "MagickCore/exception.h"
-
 typedef enum
 {
   UndefinedPolicyDomain,
diff --git a/MagickCore/profile-private.h b/MagickCore/profile-private.h
index 4adf3a7..10938b0 100644
--- a/MagickCore/profile-private.h
+++ b/MagickCore/profile-private.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_PROFILE_PRIVATE_H
 #define _MAGICKCORE_PROFILE_PRIVATE_H
 
+#include "MagickCore/string_.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/string_.h"
-
 extern MagickPrivate MagickBooleanType
   SyncImageProfiles(Image *);
 
diff --git a/MagickCore/profile.h b/MagickCore/profile.h
index 33176a6..9488548 100644
--- a/MagickCore/profile.h
+++ b/MagickCore/profile.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_PROFILE_H
 #define _MAGICKCORE_PROFILE_H
 
+#include "MagickCore/string_.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/string_.h"
-
 typedef struct _ProfileInfo
   ProfileInfo;
 
diff --git a/MagickCore/quantize.h b/MagickCore/quantize.h
index bf462dc..b1961b3 100644
--- a/MagickCore/quantize.h
+++ b/MagickCore/quantize.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_QUANTIZE_H
 #define _MAGICKCORE_QUANTIZE_H
 
+#include "MagickCore/colorspace.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/colorspace.h"
-
 typedef enum
 {
   UndefinedDitherMethod,
diff --git a/MagickCore/quantum-private.h b/MagickCore/quantum-private.h
index 470fa45..cd46e54 100644
--- a/MagickCore/quantum-private.h
+++ b/MagickCore/quantum-private.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_QUANTUM_PRIVATE_H
 #define _MAGICKCORE_QUANTUM_PRIVATE_H
 
+#include "MagickCore/cache.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/cache.h"
-
 typedef struct _QuantumState
 {
   double
diff --git a/MagickCore/quantum.h b/MagickCore/quantum.h
index ba949a7..5f2ee68 100644
--- a/MagickCore/quantum.h
+++ b/MagickCore/quantum.h
@@ -18,13 +18,13 @@
 #ifndef _MAGICKCORE_QUANTUM_H
 #define _MAGICKCORE_QUANTUM_H
 
+#include "MagickCore/image.h"
+#include "MagickCore/semaphore.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/image.h"
-#include "MagickCore/semaphore.h"
-
 typedef enum
 {
   UndefinedEndian,
diff --git a/MagickCore/random-private.h b/MagickCore/random-private.h
index 84f682c..7f0c059 100644
--- a/MagickCore/random-private.h
+++ b/MagickCore/random-private.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_RANDOM_PRIVATE_H
 #define _MAGICKCORE_RANDOM_PRIVATE_H
 
+#include "MagickCore/thread-private.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/thread-private.h"
-
 extern MagickPrivate double
   GetRandomInfoNormalize(RandomInfo *);
 
diff --git a/MagickCore/random_.h b/MagickCore/random_.h
index 57e4fec..fcf478b 100644
--- a/MagickCore/random_.h
+++ b/MagickCore/random_.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_RANDOM__H
 #define _MAGICKCORE_RANDOM__H
 
+#include "MagickCore/string_.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/string_.h"
-
 /*
   Typedef declarations.
 */
diff --git a/MagickCore/resample-private.h b/MagickCore/resample-private.h
index 9df9825..c182ca0 100644
--- a/MagickCore/resample-private.h
+++ b/MagickCore/resample-private.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_RESAMPLE_PRIVATE_H
 #define _MAGICKCORE_RESAMPLE_PRIVATE_H
 
+#include "MagickCore/thread-private.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/thread-private.h"
-
 static inline ResampleFilter **DestroyResampleFilterThreadSet(
   ResampleFilter **filter)
 {
diff --git a/MagickCore/resample.h b/MagickCore/resample.h
index 77ab870..239674a 100644
--- a/MagickCore/resample.h
+++ b/MagickCore/resample.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_RESAMPLE_H
 #define _MAGICKCORE_RESAMPLE_H
 
+#include "MagickCore/cache-view.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/cache-view.h"
-
 /*
   WARNING:  The order of this table must also match the order of a table
   located in AcquireResizeFilter() in "resize.c" otherwise the users filter
diff --git a/MagickCore/signature-private.h b/MagickCore/signature-private.h
index 6c3d329..6468876 100644
--- a/MagickCore/signature-private.h
+++ b/MagickCore/signature-private.h
@@ -18,14 +18,14 @@
 #ifndef _MAGICKCORE_SIGNATURE_PRIVATE_H
 #define _MAGICKCORE_SIGNATURE_PRIVATE_H
 
+#include "MagickCore/string_.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
 #define MagickSignatureSize  64
 
-#include "MagickCore/string_.h"
-
 typedef struct _SignatureInfo
   SignatureInfo;
 
diff --git a/MagickCore/string-private.h b/MagickCore/string-private.h
index a833a89..563df32 100644
--- a/MagickCore/string-private.h
+++ b/MagickCore/string-private.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_STRING_PRIVATE_H
 #define _MAGICKCORE_STRING_PRIVATE_H
 
+#include "MagickCore/locale_.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/locale_.h"
-
 static inline double SiPrefixToDoubleInterval(const char *string,
   const double interval)
 {
diff --git a/MagickCore/string_.h b/MagickCore/string_.h
index 589c3be..cf734cc 100644
--- a/MagickCore/string_.h
+++ b/MagickCore/string_.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_STRING_H_
 #define _MAGICKCORE_STRING_H_
 
+#include "MagickCore/exception.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/exception.h"
-
 typedef struct _StringInfo
 {
   char
diff --git a/MagickCore/thread-private.h b/MagickCore/thread-private.h
index c66abe2..b681ad5 100644
--- a/MagickCore/thread-private.h
+++ b/MagickCore/thread-private.h
@@ -18,14 +18,14 @@
 #ifndef _MAGICKCORE_THREAD_PRIVATE_H
 #define _MAGICKCORE_THREAD_PRIVATE_H
 
-#if defined(__cplusplus) || defined(c_plusplus)
-extern "C" {
-#endif
-
 #include "MagickCore/cache.h"
 #include "MagickCore/resource_.h"
 #include "MagickCore/thread_.h"
 
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 /*
   Single threaded unless workload justifies the threading overhead.
 */
diff --git a/MagickCore/utility-private.h b/MagickCore/utility-private.h
index e1314a0..783c46f 100644
--- a/MagickCore/utility-private.h
+++ b/MagickCore/utility-private.h
@@ -18,14 +18,14 @@
 #ifndef _MAGICKCORE_UTILITY_PRIVATE_H
 #define _MAGICKCORE_UTILITY_PRIVATE_H
 
-#if defined(__cplusplus) || defined(c_plusplus)
-extern "C" {
-#endif
-
 #include "MagickCore/memory_.h"
 #include "MagickCore/nt-base.h"
 #include "MagickCore/nt-base-private.h"
 
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 extern MagickPrivate char
   **GetPathComponents(const char *,size_t *),
   **ListFiles(const char *,const char *,size_t *);
diff --git a/MagickCore/version-private.h b/MagickCore/version-private.h
index 967d554..9b96eb9 100644
--- a/MagickCore/version-private.h
+++ b/MagickCore/version-private.h
@@ -18,12 +18,12 @@
 #ifndef _MAGICKCORE_VERSION_PRIVATE_H
 #define _MAGICKCORE_VERSION_PRIVATE_H
 
+#include "MagickCore/string_.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/string_.h"
-
 extern MagickExport unsigned int
   GetMagickSignature(const StringInfo *);
 
diff --git a/MagickCore/version.c b/MagickCore/version.c
index 52b2bf1..caea7da 100644
--- a/MagickCore/version.c
+++ b/MagickCore/version.c
@@ -458,6 +458,10 @@
   return(crc ^ 0xFFFFFFFF);
 }
 
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 MagickExport unsigned int GetMagickSignature(const StringInfo *nonce)
 {
   register unsigned char
@@ -490,6 +494,10 @@
   version=DestroyStringInfo(version);
   return(signature);
 }
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
 
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/MagickCore/widget-private.h b/MagickCore/widget-private.h
index eb5f742..68bebbf 100644
--- a/MagickCore/widget-private.h
+++ b/MagickCore/widget-private.h
@@ -18,14 +18,13 @@
 #ifndef _MAGICKCORE_WIDGET_PRIVATE_H
 #define _MAGICKCORE_WIDGET_PRIVATE_H
 
+#include "MagickCore/xwindow-private.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
 #if defined(MAGICKCORE_X11_DELEGATE)
-
-#include "MagickCore/xwindow-private.h"
-
 extern MagickPrivate int
   XCommandWidget(Display *,XWindows *,const char **,XEvent *),
   XConfirmWidget(Display *,XWindows *,const char *,const char *),
diff --git a/MagickCore/xml-tree-private.h b/MagickCore/xml-tree-private.h
index 2813355..a954ced 100644
--- a/MagickCore/xml-tree-private.h
+++ b/MagickCore/xml-tree-private.h
@@ -18,13 +18,13 @@
 #ifndef _MAGICKCORE_XML_TREE_PRIVATE_H
 #define _MAGICKCORE_XML_TREE_PRIVATE_H
 
+#include "MagickCore/exception.h"
+#include "MagickCore/splay-tree.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include "MagickCore/exception.h"
-#include "MagickCore/splay-tree.h"
-
 extern MagickPrivate char
   *CanonicalXMLContent(const char *,const MagickBooleanType);
 
diff --git a/MagickCore/xwindow-private.h b/MagickCore/xwindow-private.h
index 38a37bf..bace658 100644
--- a/MagickCore/xwindow-private.h
+++ b/MagickCore/xwindow-private.h
@@ -18,16 +18,16 @@
 #ifndef _MAGICKCORE_XWINDOW_PRIVATE_H
 #define _MAGICKCORE_XWINDOW_PRIVATE_H
 
-#if defined(__cplusplus) || defined(c_plusplus)
-extern "C" {
-#endif
-
 #include "MagickCore/draw.h"
 #include "MagickCore/exception.h"
 #include "MagickCore/geometry.h"
 #include "MagickCore/pixel-accessor.h"
 #include "MagickCore/quantize.h"
 
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
 #if defined(MAGICKCORE_X11_DELEGATE)
 
 #include <X11/Xos.h>