Witam.
Mam problem ze skompilowaniem przykładowej dll-ki.
#ifndef EXAMPLE_DLL_H
#define EXAMPLE_DLL_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef BUILDING_EXAMPLE_DLL
#define EXAMPLE_DLL __declspec(dllexport)
#else
#define EXAMPLE_DLL __declspec(dllimport)
#endif
void __stdcall EXAMPLE_DLL hello(const char* s);
int EXAMPLE_DLL Double(int x);
#ifdef __cplusplus
}
#endif
void EXAMPLE_DLL CppFunc(void);
class EXAMPLE_DLL MyClass
{
public:
MyClass(){};
virtual ~MyClass(){};
void func(void);
};
#endif // EXAMLE_DLL_H
#include <stdio.h>
#include "example_dll.h"
__stdcall void hello(const char* s)
{
printf("Hello %s\n", s);
}
int Double(int x)
{
return 2 * x;
}
void cppFunc(void)
{
puts("cppFunc");
}
void MyClass:func(void)
{
puts("MyClass.func()");
}
W wyniku mam taki błąd:
g++ -c -DBUILDING_EXAMPLE_DLL example_dll.cpp
In file included from example_dll.cpp:2:0:
example_dll.h:14:16: error: expected initializer before ‘__declspec’
example_dll.h:16:5: error: ‘dllexport’ was not declared in this scope
example_dll.h:16:17: error: expected ‘,’ or ‘;’ before ‘Double’
example_dll.h:22:6: error: variable or field ‘__declspec’ declared void
example_dll.h:22:6: error: ‘dllexport’ was not declared in this scope
example_dll.h:24:19: error: expected initializer before ‘MyClass’
Wersja gcc: 4.7.2
Będę wdzięczny za pomoc.