Witam.
Chcę w CodeBlock napisać własną dll, korzystając z szablonu potrafię napisać prostą bibliotekę, jednak nie potrafię tego zrobić kiedy chcę wykorzystać funkcję z zewnętrznych plików
W tym przypadku chcę skompilować dll z funkcją feed_layer(). Co robię źlę?
||=== Build: Release in test (compiler: GNU GCC Compiler x64) ===|
C:\Users\xXx\Desktop\Błażej\AHK\Projects\neural network 0.2\dll\test\main.h|22|error: expected initializer before 'feed_layer'|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
// main.h
#ifndef __MAIN_H__
#define __MAIN_H__
#include <windows.h>
/* To use this exported function of dll, include this header
* in your project.
*/
#ifdef BUILD_DLL
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT __declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C"
{
#endif
void DLL_EXPORT SomeFunction(const LPCSTR sometext);
float DLLIMPORT feed_layer(t_layer* layer,matrixR* input,f dot);
#ifdef __cplusplus
}
#endif
#endif // __MAIN_H__
// main.cpp
#include "main.h"
#include "nn.h"
// a sample exported function
void DLL_EXPORT SomeFunction(const LPCSTR sometext)
{
MessageBoxA(0, sometext, "DLL Message", MB_OK | MB_ICONINFORMATION);
}
extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
// attach to process
// return FALSE to fail DLL load
break;
case DLL_PROCESS_DETACH:
// detach from process
break;
case DLL_THREAD_ATTACH:
// attach to thread
break;
case DLL_THREAD_DETACH:
// detach from thread
break;
}
return TRUE; // succesful
}
// nn.h
#ifndef _NN_
#define _NN_
#include <stdint.h>
typedef void (*f)(uint8_t,uint8_t,uint8_t,int,int,int,float,float*,int,float*,int,float,float*,int);
struct matrixR
{
uint32_t rowsN;
uint32_t colsN;
float* matrix;
};
enum CBLAS_TRANSPOSE {
CblasNoTrans=111,
CblasTrans=112,
CblasConjTrans=113,
AtlasConj=114
};
struct t_layer
{
uint32_t type;
uint32_t aFunction;
matrixR* weights;
matrixR* net;
matrixR* out;
matrixR* weightsR;
matrixR* outT01;
};
float feed_layer(t_layer* layer,matrixR* input,f dot);
#endif // _NN_
// nn.cpp
#include "nn.h"
#define _dot(tA,A,tB,B,C ,alpha,beta) dot(101,tA,tB,C->rowsN,C->colsN,tA==CblasNoTrans?A->colsN:A->rowsN,alpha,A->matrix,A->colsN,B->matrix,B->colsN,beta,C->matrix,C->colsN);
float feed_layer(t_layer* layer,matrixR* input,f dot){
uint32_t type = layer->type;
// for(int i=0;i<1000;i++)
{
switch(type){
case 0: // FF
_dot(CblasNoTrans,input,CblasNoTrans,layer->weights,layer->net,1,0);
break;
case 1: // RNN
_dot( CblasNoTrans , input , CblasNoTrans , layer->weights , layer->net ,1,0);
_dot( CblasNoTrans , layer->outT01 , CblasNoTrans , layer->weightsR , layer->net ,1,0);
break;
}
}
return type;
}