[build] Really fix multi and C++ builds. The following builds were still failing due to previous changes: make multi make multi CC="c++" make CC="c++" This patch fixes the issues, which were missing includes to get the right macro definitions in multi-build mode. Also, `FT_UNUSED' is actually used by third-party code, so move it back to `public-macros.h' to avoid breaking it. * include/freetype/config/public-macros.h (FT_EXPORT): Remove special definition for C++. (FT_UNUSED): Define here instead of... * include/freetype/config/compiler-macros.h: ... here. (FT_FUNCTION_DECLARATION): Remove special definition for C++. (FT_LOCAL_ARRAY_DEF): Fix definition. * src/cache/ftccback.h, src/lzw/ftzopen.h, src/gxvalid/gxvmort.h, src/gxvalid/gxvmorx.h: Add `FT_BEGIN_HEADER' and `FT_END_HEADER'.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
diff --git a/ChangeLog b/ChangeLog
index 7bf83a0..39d2e89 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2020-07-07 David Turner <david@freetype.org>
+
+ [build] Really fix multi and C++ builds.
+
+ The following builds were still failing due to previous changes:
+
+ make multi
+ make multi CC="c++"
+ make CC="c++"
+
+ This patch fixes the issues, which were missing includes to get the
+ right macro definitions in multi-build mode.
+
+ Also, `FT_UNUSED' is actually used by third-party code, so move it
+ back to `public-macros.h' to avoid breaking it.
+
+ * include/freetype/config/public-macros.h (FT_EXPORT): Remove
+ special definition for C++.
+ (FT_UNUSED): Define here instead of...
+ * include/freetype/config/compiler-macros.h: ... here.
+ (FT_FUNCTION_DECLARATION): Remove special definition for C++.
+ (FT_LOCAL_ARRAY_DEF): Fix definition.
+
+ * src/cache/ftccback.h, src/lzw/ftzopen.h, src/gxvalid/gxvmort.h,
+ src/gxvalid/gxvmorx.h: Add `FT_BEGIN_HEADER' and `FT_END_HEADER'.
+
2020-07-06 David Turner <david@freetype.org>
[build] Fix multi and C++ builds.
diff --git a/include/freetype/config/public-macros.h b/include/freetype/config/public-macros.h
index b1fa0f2..5cc3236 100644
--- a/include/freetype/config/public-macros.h
+++ b/include/freetype/config/public-macros.h
@@ -78,13 +78,23 @@ FT_BEGIN_HEADER
*
* FT_EXPORT( FT_Bool ) FT_Object_Method( FT_Object obj, ... );
*
+ * NOTE: This requires that all FT_EXPORT() uses are inside FT_BEGIN_HEADER ..
+ * FT_END_HEADER blocks. This guarantees that the functions are exported with
+ * C linkage, even when the header is included by a C++ source file.
*/
-#ifdef __cplusplus
-#define FT_EXPORT( x ) FT_PUBLIC_FUNCTION_ATTRIBUTE extern "C" x
-#else
#define FT_EXPORT( x ) FT_PUBLIC_FUNCTION_ATTRIBUTE extern x
+
+ /* `FT_UNUSED` indicates that a given parameter is not used -- */
+ /* this is only used to get rid of unpleasant compiler warnings. */
+ /* */
+ /* Technically, this was not meant to be part of the public API, */
+ /* but some third-party code depends on it. */
+ /* */
+#ifndef FT_UNUSED
+#define FT_UNUSED( arg ) ( (arg) = (arg) )
#endif
+
FT_END_HEADER
#endif /* FREETYPE_CONFIG_PUBLIC_MACROS_H_ */
diff --git a/include/freetype/internal/compiler-macros.h b/include/freetype/internal/compiler-macros.h
index 1f432bc..b62c077 100644
--- a/include/freetype/internal/compiler-macros.h
+++ b/include/freetype/internal/compiler-macros.h
@@ -29,12 +29,6 @@ FT_BEGIN_HEADER
# endif
#endif
- /* `FT_UNUSED` indicates that a given parameter is not used -- */
- /* this is only used to get rid of unpleasant compiler warnings. */
-#ifndef FT_UNUSED
-#define FT_UNUSED( arg ) ( (arg) = (arg) )
-#endif
-
/* Fix compiler warning with sgi compiler. */
#if defined( __sgi ) && !defined( __GNUC__ )
# if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 )
@@ -126,18 +120,13 @@ FT_BEGIN_HEADER
*
* FT_FUNCTION_DECLARATION(int) foo(int x);
*
- * NOTE: Technically, all FreeType headers put their function declarations
- * inside an extern "C" block, giving them C linkage. This means that using
- * this macro is only necessary within internal source files, but using it in
- * a header will be harmless.
+ * NOTE: This requires that all uses are inside FT_BEGIN_HEADER..FT_END_HEADER
+ * blocks. Which guarantees that the declarations have C linkage when the
+ * headers are included by C++ sources.
*
* NOTE: Do not use directly, use FT_LOCAL()/FT_BASE()/FT_EXPORT() instead.
*/
-#ifdef __cplusplus
-#define FT_FUNCTION_DECLARATION( x ) extern "C" x
-#else
#define FT_FUNCTION_DECLARATION( x ) extern x
-#endif
/* Same as FT_FUNCTION_DECLARATION(), but for function definitions instead.
* NOTE: Do not use directly, use FT_LOCAL_DEF()/FT_BASE_DEF()/FT_EXPORT_DEF()
@@ -171,7 +160,7 @@ FT_BEGIN_HEADER
* sub-directory, but are otherwise internal to the library.
*/
#define FT_LOCAL_ARRAY( x ) FT_INTERNAL_FUNCTION_ATTRIBUTE extern const x
-#define FT_LOCAL_ARRAY_DEF( x ) const x
+#define FT_LOCAL_ARRAY_DEF( x ) FT_FUNCTION_DEFINITION( const x )
/* Use FT_BASE()/FT_BASE_DEF() to declare or define an internal library
* function that are used by more than one single module.
diff --git a/src/cache/ftccback.h b/src/cache/ftccback.h
index 802fd44..542acb1 100644
--- a/src/cache/ftccback.h
+++ b/src/cache/ftccback.h
@@ -25,6 +25,7 @@
#include "ftcglyph.h"
#include "ftcsbits.h"
+FT_BEGIN_HEADER
FT_LOCAL( void )
ftc_inode_free( FTC_Node inode,
@@ -84,6 +85,7 @@
ftc_node_destroy( FTC_Node node,
FTC_Manager manager );
+FT_END_HEADER
#endif /* FTCCBACK_H_ */
diff --git a/src/gxvalid/gxvmort.h b/src/gxvalid/gxvmort.h
index 24c7e45..7237c58 100644
--- a/src/gxvalid/gxvmort.h
+++ b/src/gxvalid/gxvmort.h
@@ -34,6 +34,9 @@
#include <freetype/ftsnames.h>
+FT_BEGIN_HEADER
+
+
typedef struct GXV_mort_featureRec_
{
FT_UShort featureType;
@@ -88,6 +91,8 @@
GXV_Validator gxvalid );
+FT_END_HEADER
+
#endif /* GXVMORT_H_ */
diff --git a/src/gxvalid/gxvmorx.h b/src/gxvalid/gxvmorx.h
index ceb14a9..f747b1d 100644
--- a/src/gxvalid/gxvmorx.h
+++ b/src/gxvalid/gxvmorx.h
@@ -36,6 +36,9 @@
#include <freetype/ftsnames.h>
+FT_BEGIN_HEADER
+
+
FT_LOCAL( void )
gxv_morx_subtable_type0_validate( FT_Bytes table,
FT_Bytes limit,
@@ -62,6 +65,8 @@
GXV_Validator gxvalid );
+FT_END_HEADER
+
#endif /* GXVMORX_H_ */
diff --git a/src/lzw/ftzopen.h b/src/lzw/ftzopen.h
index cb9206b..d8768f7 100644
--- a/src/lzw/ftzopen.h
+++ b/src/lzw/ftzopen.h
@@ -24,6 +24,7 @@
#include <freetype/freetype.h>
+FT_BEGIN_HEADER
/*
* This is a complete re-implementation of the LZW file reader,
@@ -165,6 +166,8 @@
/* */
+FT_END_HEADER
+
#endif /* FTZOPEN_H_ */