Subject | DLL help please |
---|---|
Author | westley52 |
Post date | 2006-12-15T10:36:17Z |
I am experimenting creating a dll for firebird - thought I would try
something simple. I created one where I just took a parameter and
returned it, and it worked fine. However, when I created a minor
change, such as adding to parameters together and returning that, I
consistently get an incorrect return of 0.
The strange thing is that I can use the same dll in other languages
and it returns the parameters properly added together. So, I am a bit
lost as to what is going wrong in Firebird.
I am using Firebird 2.0 on Windows XP using wx-Dev-C++ ver. 6.9 to
create a C dll. Any help/insight would be appreciated. Following is
the code. Thanks!
testdll.h
#ifndef _TESTDLL_H_
#define _TESTDLL_H_
#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */
DLLIMPORT int addfunc( int, int );
#endif /* _TESTDLL_H_ */
testdll.c
#include "testdll.h"
DLLIMPORT int addfunc( int a, int b )
{
return a + b;
}
testdll.sql
DECLARE EXTERNAL FUNCTION addfunc
INTEGER, INTEGER
RETURNS INTEGER
ENTRY_POINT 'addfunc' MODULE_NAME 'testdll';
something simple. I created one where I just took a parameter and
returned it, and it worked fine. However, when I created a minor
change, such as adding to parameters together and returning that, I
consistently get an incorrect return of 0.
The strange thing is that I can use the same dll in other languages
and it returns the parameters properly added together. So, I am a bit
lost as to what is going wrong in Firebird.
I am using Firebird 2.0 on Windows XP using wx-Dev-C++ ver. 6.9 to
create a C dll. Any help/insight would be appreciated. Following is
the code. Thanks!
testdll.h
#ifndef _TESTDLL_H_
#define _TESTDLL_H_
#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */
DLLIMPORT int addfunc( int, int );
#endif /* _TESTDLL_H_ */
testdll.c
#include "testdll.h"
DLLIMPORT int addfunc( int a, int b )
{
return a + b;
}
testdll.sql
DECLARE EXTERNAL FUNCTION addfunc
INTEGER, INTEGER
RETURNS INTEGER
ENTRY_POINT 'addfunc' MODULE_NAME 'testdll';