From 92bff78fbd63085c1b7478f66b9f94de6c0d991d Mon Sep 17 00:00:00 2001 From: stevenj Date: Fri, 2 Apr 2010 18:50:04 -0400 Subject: [PATCH] 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 --- api/nlopt.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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 -- 2.30.2