Commits

Ondřej Surý  committed 173bd59

Fix Win32 build regression and also fix Win32 static build in one go. Also define new BGD_STDCALL __stdcall on Win32 and use it in other source files.

  • Participants
  • Parent commits b4b3e60

Comments (1)

  1. Marcin Wojdyr

    I can't find an easy way to build a program with static gd on Windows now. I need to avoid dllimport otherwise the lib has _gdImageSetTile@8 and program expects __imp__gdImageSetTile@8.

    Adding -DBGDWIN32 -DNONDLL works, but it's rather hackish.

    I guess one -D is necessary, but ideally it would be more descriptive like GD_NONDLL or GD_DLL.

    Thoughts?

Files changed (3)

-
 #ifdef __cplusplus
 extern "C" {
 #endif
    wish to build gd as a static library or by directly including
    the gd sources in a project. */
 
-#if !defined(WIN32) && !defined(_WIN32_WCE) && !defined(CYGWIN)
-#define NONDLL 1
-#endif /* WIN32 */
-
 /* http://gcc.gnu.org/wiki/Visibility */
 #if defined(WIN32) || defined(CYGWIN) || defined(_WIN32_WCE)
-# if !defined(NONDLL) || defined(BUILDING_DLL)
-#  ifdef __GNUC__
-#   define BGD_EXPORT_DATA_PROT __attribute__ ((dllexport))
+# if BGDWIN32
+#  ifdef NONDLL
+#   ifdef __GNUC__
+#    define BGD_EXPORT_DATA_PROT __attribute__ ((dllimport))
+#   else
+#    define BGD_EXPORT_DATA_PROT __declspec(dllimport)
+#   endif
 #  else
-#   define BGD_EXPORT_DATA_PROT __declspec(dllexport)
+#   ifdef __GNUC__
+#    define BGD_EXPORT_DATA_PROT __attribute__ ((dllexport))
+#   else
+#    define BGD_EXPORT_DATA_PROT __declspec(dllexport)
+#   endif
 #  endif
 # else
-#  ifdef __GNUC__
-#   define BGD_EXPORT_DATA_PROT __attribute__ ((dllimport))
-#  else
-#   define BGD_EXPORT_DATA_PROT __declspec(dllimport)
-#  endif
+#  define BGD_EXPORT_DATA_PROT
 # endif
+# define BGD_STDCALL __stdcall
 # define BGD_EXPORT_DATA_IMPL
-# define BGD_DECLARE(rt) BGD_EXPORT_DATA_PROT rt __stdcall
 #else
 # ifdef HAVE_VISIBILITY
 #  define BGD_EXPORT_DATA_PROT __attribute__ ((visibility ("default")))
 #  define BGD_EXPORT_DATA_PROT
 #  define BGD_EXPORT_DATA_IMPL
 # endif
-# define BGD_DECLARE(rt) BGD_EXPORT_DATA_PROT rt
+# define BGD_STDCALL
 #endif
 
+#define BGD_DECLARE(rt) BGD_EXPORT_DATA_PROT rt BGD_STDCALL
+
 #ifdef __cplusplus
 	extern "C"
 	{

File src/gd_filter.c

 #include <stdlib.h>
 #include <time.h>
 
-#ifdef NONDLL
-#define __stdcall
-#endif
-
-typedef int (__stdcall *FuncPtr)(gdImagePtr, int, int);
+typedef int (GD_STDCALL *FuncPtr)(gdImagePtr, int, int);
 
 #define GET_PIXEL_FUNCTION(src)(src->trueColor?gdImageGetTrueColorPixel:gdImageGetPixel)
 #define MIN(a,b) ((a)<(b)?(a):(b))

File src/gd_rotate.c

 #undef ROTATE_PI
 #endif /* ROTATE_PI */
 
-#ifdef NONDLL
-#define __stdcall
-#endif
-
-typedef int (__stdcall *FuncPtr)(gdImagePtr, int, int);
+typedef int (BGD_STDCALL *FuncPtr)(gdImagePtr, int, int);
 
 #define ROTATE_DEG2RAD  3.1415926535897932384626433832795/180
 void gdImageSkewX (gdImagePtr dst, gdImagePtr src, int uRow, int iOffset, double dWeight, int clrBack, int ignoretransparent)