diff --git a/include/mujoco/mjplugin.h b/include/mujoco/mjplugin.h index 1ce1b5e5..eccf9d22 100644 --- a/include/mujoco/mjplugin.h +++ b/include/mujoco/mjplugin.h @@ -72,15 +72,23 @@ typedef struct mjpPlugin_ mjpPlugin; #define mjDLLMAIN DllMain #endif +#if !defined(mjEXTERNC) +#if defined(__cplusplus) +#define mjEXTERNC extern "C" +#else +#define mjEXTERNC +#endif // defined(__cplusplus) +#endif // !defined(mjEXTERNC) + // NOLINTBEGIN(runtime/int) -#define mjPLUGIN_DYNAMIC_LIBRARY_INIT \ - static void _mjplugin_dllmain(void); \ - static int __stdcall mjDLLMAIN(void* hinst, unsigned long reason, void* reserved) { \ - if (reason == 1) { \ - _mjplugin_dllmain(); \ - } \ - return 1; \ - } \ +#define mjPLUGIN_DYNAMIC_LIBRARY_INIT \ + static void _mjplugin_dllmain(void); \ + mjEXTERNC int __stdcall mjDLLMAIN(void* hinst, unsigned long reason, void* reserved) { \ + if (reason == 1) { \ + _mjplugin_dllmain(); \ + } \ + return 1; \ + } \ static void _mjplugin_dllmain(void) // NOLINTEND(runtime/int) diff --git a/unity/Runtime/Bindings/MujocoBindings.cs b/unity/Runtime/Bindings/MujocoBindings.cs index 47b8c204..940e6624 100644 --- a/unity/Runtime/Bindings/MujocoBindings.cs +++ b/unity/Runtime/Bindings/MujocoBindings.cs @@ -50,6 +50,7 @@ public const int mjNREF = 2; public const int mjNIMP = 5; public const int mjNSOLVER = 1000; public const bool THIRD_PARTY_MUJOCO_INCLUDE_MJPLUGIN_H_ = true; +public const bool mjEXTERNC = true; public const bool THIRD_PARTY_MUJOCO_MJRENDER_H_ = true; public const int mjNAUX = 10; public const int mjMAXTEXTURE = 1000;