chiark / gitweb /
use stdcall interface by default on Windows, since this seems to be more standard...
authorstevenj <stevenj@alum.mit.edu>
Fri, 2 Apr 2010 22:50:04 +0000 (18:50 -0400)
committerstevenj <stevenj@alum.mit.edu>
Fri, 2 Apr 2010 22:50:04 +0000 (18:50 -0400)
darcs-hash:20100402225004-c8de0-40e1743d311901ea1ccf0dea3588d654474b050d.gz

api/nlopt.h

index 19fbe47233be4663a118933567a9ec48cb8a010f..61ae819b165d3393f2d823eedf45938e5168aea6 100644 (file)
 
 #include <stddef.h> /* for ptrdiff_t */
 
+/* use stdcall convention under Windows, since this seems to
+   be more standard there and is important for calling from .NET */
+#if defined(_WIN32) || defined(__WIN32__)
+#  if defined(__GNUC__)
+#    define NLOPT_STDCALL __attribute__((stdcall))
+#  elif defined(_MSC_VER) || defined(_ICC) || defined(_STDCALL_SUPPORTED)
+#    define NLOPT_STDCALL __stdcall
+#  else
+#    define NLOPT_STDCALL
+#  endif
+#else
+#  define NLOPT_STDCALL
+#endif
+
 /* for Windows compilers, you should add a line
            #define NLOPT_DLL
    when using NLopt from a DLL, in order to do the proper
    Windows importing nonsense. */
 #if defined(NLOPT_DLL) && (defined(_WIN32) || defined(__WIN32__))
 /* annoying Windows syntax for calling functions in a DLL */
-#  define NLOPT_EXTERN extern __declspec(dllimport)
+#  define NLOPT_EXTERN extern __declspec(dllimport) NLOPT_STDCALL
 #else
-#  define NLOPT_EXTERN extern
+#  define NLOPT_EXTERN extern NLOPT_STDCALL
 #endif
 
 #ifdef __cplusplus