| re: dll help, syntax question
sorry, my mistake, i should ask this in comp.lang.c :) I don't mind if you
answer it anyway though!
"Jason" <jason.carney1@btinternet.com> wrote in message
news:buh21g$fpi$1@titan.btinternet.com...[color=blue]
> Hello, I've got an example from the mingw website of creating a dll. It[/color]
is[color=blue]
> 3 files: a header, .c file and another file containing main. I want to use
> the dll in VB and it works for tstfunc, but I am not able to use tststr as
> it wont export.
>
> header file:
>
> #ifdef BUILD_DLL
> // the dll exports
> #define EXPORT __declspec(dllexport)
> #else
> // the exe imports
> #define EXPORT __declspec(dllimport)
> #endif
>
> // function to be imported/exported
> EXPORT int tstfunc (void);
>
> EXPORT long tststr (void); //I want to use function too
>
> .c file
>
> #include <stdio.h>
> #include "dllfct.h"
>
> EXPORT int tstfunc (void)
> {
> return 200;
> }
>
> EXPORT long tststr (void) { //am returning a long due to wanting to use
> the pointer in VB because
> //experimenting with what
> values I can return and use from the dll
> char p[10];
> p = (char *) "hello\0";
> return (long *) p;
> }
>
> If I do the below it gives me an error at compile time due to an undefined
> reference to _imp__tststr, the name of the second function I wish to[/color]
export.[color=blue]
>
> #include "dllfct.h"
>
> int main ()
> {
> tstfunc ();
> tststr();
> return (0);
> }
>
> I guess I need to change this to export the second function, but how?[/color]
What[color=blue]
> does it mean?
>
> #ifdef BUILD_DLL
> // the dll exports
> #define EXPORT __declspec(dllexport)
> #else
> // the exe imports
> #define EXPORT __declspec(dllimport)
> #endif
>
>
>
> Thanks for any help.
>
>
>[/color] |