Removing FT_MAKE_OPTION_SINGLE_LIBRARY_OBJECT. It has never worked. Instead, define BASE_DEF() and BASE_FUNC() similarly to FT_EXPORT_DEF() and FT_EXPORT_FUNC(), respectively, allowing the programmer to define proper types and/or export lists for multiple DLLs if necessary (e.g. ftbase.dll -- standalone, fttype1.dll -- needs ftbase.dll, etc.). The library is finally compiling and linking natively with a C++ compiler!
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 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
diff --git a/include/freetype/config/ftconfig.h b/include/freetype/config/ftconfig.h
index bf4d331..a2e9842 100644
--- a/include/freetype/config/ftconfig.h
+++ b/include/freetype/config/ftconfig.h
@@ -159,33 +159,78 @@
#ifdef FT_MAKE_OPTION_SINGLE_OBJECT
-#define LOCAL_DEF static
-#define LOCAL_FUNC static
+
+#define LOCAL_DEF static
+#define LOCAL_FUNC static
+
+#else
+
+#ifdef __cplusplus
+#define LOCAL_DEF extern "C"
+#define LOCAL_FUNC extern "C"
#else
-#define LOCAL_DEF extern
-#define LOCAL_FUNC /* nothing */
+#define LOCAL_DEF extern
+#define LOCAL_FUNC extern
#endif
-#ifdef FT_MAKE_OPTION_SINGLE_LIBRARY_OBJECT
-#define BASE_DEF( x ) static x
-#define BASE_FUNC( x ) static x
+#endif /* FT_MAKE_OPTION_SINGLE_OBJECT */
+
+
+#ifndef BASE_DEF
+
+#ifdef __cplusplus
+#define BASE_DEF( x ) extern "C" x
#else
-#define BASE_DEF( x ) extern x
-#define BASE_FUNC( x ) extern x
+#define BASE_DEF( x ) extern x
#endif
-#ifndef FT_EXPORT_DEF
-#define FT_EXPORT_DEF( x ) extern x
+#endif /* !BASE_DEF */
+
+
+#ifndef BASE_FUNC
+
+#ifdef __cplusplus
+#define BASE_FUNC( x ) extern "C" x
+#else
+#define BASE_FUNC( x ) extern x
#endif
-#ifndef FT_EXPORT_FUNC
-#define FT_EXPORT_FUNC( x ) extern x
+#endif /* !BASE_FUNC */
+
+
+#ifndef FT_EXPORT_DEF
+
+#ifdef __cplusplus
+#define FT_EXPORT_DEF( x ) extern "C" x
+#else
+#define FT_EXPORT_DEF( x ) extern x
+#endif
+
+#endif /* !FT_EXPORT_DEF */
+
+
+#ifndef FT_EXPORT_FUNC
+
+#ifdef __cplusplus
+#define FT_EXPORT_FUNC( x ) extern "C" x
+#else
+#define FT_EXPORT_FUNC( x ) extern x
#endif
-#ifndef FT_EXPORT_VAR
-#define FT_EXPORT_VAR( x ) extern x
+#endif /* !FT_EXPORT_FUNC */
+
+
+#ifndef FT_EXPORT_VAR
+
+#ifdef __cplusplus
+#define FT_EXPORT_VAR( x ) extern "C" x
+#else
+#define FT_EXPORT_VAR( x ) extern x
#endif
+#endif /* !FT_EXPORT_VAR */
+
+
#ifdef __cplusplus
}
#endif
diff --git a/src/autohint/ahmodule.c b/src/autohint/ahmodule.c
index 8575568..255d542 100644
--- a/src/autohint/ahmodule.c
+++ b/src/autohint/ahmodule.c
@@ -107,7 +107,7 @@
};
- const FT_Module_Class autohint_module_class =
+ FT_EXPORT_VAR( const FT_Module_Class ) autohint_module_class =
{
ft_module_hinter,
sizeof ( FT_AutoHinterRec ),
diff --git a/src/base/ftinit.c b/src/base/ftinit.c
index 8cfc0de..ed060d5 100644
--- a/src/base/ftinit.c
+++ b/src/base/ftinit.c
@@ -53,7 +53,11 @@
#define FT_COMPONENT trace_init
#undef FT_USE_MODULE
+#ifdef __cplusplus
+#define FT_USE_MODULE( x ) extern "C" const FT_Module_Class* x;
+#else
#define FT_USE_MODULE( x ) extern const FT_Module_Class* x;
+#endif
#include <freetype/config/ftmodule.h>
diff --git a/src/cff/t2driver.c b/src/cff/t2driver.c
index d1e1b18..ab6c20f 100644
--- a/src/cff/t2driver.c
+++ b/src/cff/t2driver.c
@@ -302,7 +302,7 @@
/* The FT_DriverInterface structure is defined in ftdriver.h. */
- const FT_Driver_Class cff_driver_class =
+ FT_EXPORT_VAR( const FT_Driver_Class ) cff_driver_class =
{
/* begin with the FT_Module_Class fields */
{
diff --git a/src/cid/cidriver.c b/src/cid/cidriver.c
index f1c6b6a..b4f0fd7 100644
--- a/src/cid/cidriver.c
+++ b/src/cid/cidriver.c
@@ -182,7 +182,7 @@
}
- const FT_Driver_Class t1cid_driver_class =
+ FT_EXPORT_VAR( const FT_Driver_Class ) t1cid_driver_class =
{
/* first of all, the FT_Module_Class fields */
{
diff --git a/src/psnames/psmodule.c b/src/psnames/psmodule.c
index 55ab5df..448ea18 100644
--- a/src/psnames/psmodule.c
+++ b/src/psnames/psmodule.c
@@ -296,7 +296,7 @@
#endif /* !FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES */
- const FT_Module_Class psnames_module_class =
+ FT_EXPORT_VAR( const FT_Module_Class ) psnames_module_class =
{
0, /* this is not a font driver, nor a renderer */
sizeof( FT_ModuleRec ),
diff --git a/src/raster1/ftrend1.c b/src/raster1/ftrend1.c
index d774cf1..9364864 100644
--- a/src/raster1/ftrend1.c
+++ b/src/raster1/ftrend1.c
@@ -213,7 +213,7 @@
}
- const FT_Renderer_Class ft_raster1_renderer_class =
+ FT_EXPORT_VAR( const FT_Renderer_Class ) ft_raster1_renderer_class =
{
{
ft_module_renderer,
@@ -241,10 +241,11 @@
};
- /* this renderer is _NOT_ part of the default modules, you'll need */
- /* to register it by hand in your application. It should only be */
- /* used for backwards-compatibility with FT 1.x anyway. */
- const FT_Renderer_Class ft_raster5_renderer_class =
+ /* This renderer is _NOT_ part of the default modules; you will need */
+ /* to register it by hand in your application. It should only be */
+ /* used for backwards-compatibility with FT 1.x anyway. */
+ /* */
+ FT_EXPORT_VAR( const FT_Renderer_Class ) ft_raster5_renderer_class =
{
{
ft_module_renderer,
diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c
index 96a738b..dfeb711 100644
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -204,8 +204,7 @@
};
- const
- FT_Module_Class sfnt_module_class =
+ FT_EXPORT_VAR( const FT_Module_Class ) sfnt_module_class =
{
0, /* not a font driver or renderer */
sizeof( FT_ModuleRec ),
diff --git a/src/smooth/ftsmooth.c b/src/smooth/ftsmooth.c
index 6f399ac..f040846 100644
--- a/src/smooth/ftsmooth.c
+++ b/src/smooth/ftsmooth.c
@@ -189,7 +189,7 @@
}
- const FT_Renderer_Class ft_smooth_renderer_class =
+ FT_EXPORT_VAR( const FT_Renderer_Class ) ft_smooth_renderer_class =
{
{
ft_module_renderer,
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index 0b3cb48..9e19f28 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -430,7 +430,7 @@
/* The FT_DriverInterface structure is defined in ftdriver.h. */
- const FT_Driver_Class tt_driver_class =
+ FT_EXPORT_VAR( const FT_Driver_Class ) tt_driver_class =
{
{
ft_module_font_driver |
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index 49b5a56..603546c 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -324,7 +324,7 @@
- const FT_Driver_Class t1_driver_class =
+ FT_EXPORT_VAR( const FT_Driver_Class ) t1_driver_class =
{
{
ft_module_font_driver | ft_module_driver_scalable,
diff --git a/src/type1z/z1driver.c b/src/type1z/z1driver.c
index aea2c10..ef6570d 100644
--- a/src/type1z/z1driver.c
+++ b/src/type1z/z1driver.c
@@ -283,7 +283,7 @@
}
- const FT_Driver_Class t1_driver_class =
+ FT_EXPORT_VAR( const FT_Driver_Class ) t1_driver_class =
{
{
ft_module_font_driver | ft_module_driver_scalable,
diff --git a/src/winfonts/winfnt.c b/src/winfonts/winfnt.c
index 79a549e..99f29e8 100644
--- a/src/winfonts/winfnt.c
+++ b/src/winfonts/winfnt.c
@@ -588,7 +588,7 @@
}
- const FT_Driver_Class winfnt_driver_class =
+ FT_EXPORT_VAR( const FT_Driver_Class ) winfnt_driver_class =
{
{
ft_module_font_driver,