From: stevenj Date: Fri, 2 Apr 2010 22:50:04 +0000 (-0400) Subject: use stdcall interface by default on Windows, since this seems to be more standard... X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=92bff78fbd63085c1b7478f66b9f94de6c0d991d;p=nlopt.git use stdcall interface by default on Windows, since this seems to be more standard there; thanks to Alan Young for the suggestion darcs-hash:20100402225004-c8de0-40e1743d311901ea1ccf0dea3588d654474b050d.gz --- diff --git a/api/nlopt.h b/api/nlopt.h index 19fbe47..61ae819 100644 --- a/api/nlopt.h +++ b/api/nlopt.h @@ -25,15 +25,29 @@ #include /* 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