1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-19 21:10:12 +02:00

Fixed linker problems.

This commit is contained in:
Michał W. Urbańczyk 2009-08-05 12:24:31 +00:00
parent 48581962ab
commit 64f098017b
3 changed files with 26 additions and 15 deletions

View File

@ -1,8 +1,6 @@
#ifndef __GENIUS_COMMON__ #ifndef __GENIUS_COMMON__
#define __GENIUS_COMMON__ #define __GENIUS_COMMON__
#define VCMI_DLL
#ifdef __GNUC__ #ifdef __GNUC__
#define strcpy_s(a, b, c) strncpy(a, c, b) #define strcpy_s(a, b, c) strncpy(a, c, b)
#endif #endif

View File

@ -1,4 +1,3 @@
#define VCMI_DLL
#pragma warning (disable: 4100 4251 4245 4018 4081) #pragma warning (disable: 4100 4251 4245 4018 4081)
#include "../../AI_Base.h" #include "../../AI_Base.h"
#pragma warning (default: 4100 4251 4245 4018 4081) #pragma warning (default: 4100 4251 4245 4018 4081)
@ -9,28 +8,28 @@ using namespace GeniusAI;
const char *g_cszAiName = "Genius 1.0"; const char *g_cszAiName = "Genius 1.0";
extern "C" DLL_EXPORT int GetGlobalAiVersion() extern "C" DLL_F_EXPORT int GetGlobalAiVersion()
{ {
return AI_INTERFACE_VER; return AI_INTERFACE_VER;
} }
extern "C" DLL_EXPORT void GetAiName(char* name) extern "C" DLL_F_EXPORT void GetAiName(char* name)
{ {
strcpy_s(name, strlen(g_cszAiName) + 1, g_cszAiName); strcpy_s(name, strlen(g_cszAiName) + 1, g_cszAiName);
} }
extern "C" DLL_EXPORT char* GetAiNameS() extern "C" DLL_F_EXPORT char* GetAiNameS()
{ {
// need to be defined // need to be defined
return NULL; return NULL;
} }
extern "C" DLL_EXPORT CGlobalAI* GetNewAI() extern "C" DLL_F_EXPORT CGlobalAI* GetNewAI()
{ {
return new CGeniusAI(); return new CGeniusAI();
} }
extern "C" DLL_EXPORT void ReleaseAI(CGlobalAI* i) extern "C" DLL_F_EXPORT void ReleaseAI(CGlobalAI* i)
{ {
delete (CGeniusAI*)i; delete (CGeniusAI*)i;
} }

View File

@ -84,20 +84,34 @@ const int SPELL_LEVELS = 5;
#define DEFBYPASS #define DEFBYPASS
#ifdef _WIN32 #ifdef _WIN32
#ifdef VCMI_DLL #define DLL_F_EXPORT __declspec(dllexport)
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT __declspec(dllimport)
#endif
#else #else
#if defined(__GNUC__) && __GNUC__ >= 4 #if defined(__GNUC__) && __GNUC__ >= 4
#define DLL_EXPORT __attribute__ ((visibility("default"))) #define DLL_F_EXPORT __attribute__ ((visibility("default")))
#else #else
#define DLL_EXPORT #define DLL_F_EXPORT
#endif #endif
#endif #endif
#ifdef _WIN32
#define DLL_F_IMPORT __declspec(dllimport)
#else
#if defined(__GNUC__) && __GNUC__ >= 4
#define DLL_F_IMPORT __attribute__ ((visibility("default")))
#else
#define DLL_F_IMPORT
#endif
#endif
#ifdef VCMI_DLL
#define DLL_EXPORT DLL_F_EXPORT
#else
#define DLL_EXPORT DLL_F_IMPORT
#endif
template<typename T, size_t N> char (&_ArrayCountObj(const T (&)[N]))[N]; template<typename T, size_t N> char (&_ArrayCountObj(const T (&)[N]))[N];
#define ARRAY_COUNT(arr) (sizeof(_ArrayCountObj(arr))) #define ARRAY_COUNT(arr) (sizeof(_ArrayCountObj(arr)))