This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: how to include some dll functions in a project


Hello,

Looking more closely at the code I see a subtle difference between:

  if(DYNCALL(findHidDevice(VID, PID))) printf("\r\nopened");
  DYNCALL(writeData)((UCHAR *)"11");

DYNCALL is apparently a macro. On the first call the function arguments are included in the macro parameter and on the second call apparently not. Could this be the error ? 

Note that the following instruction uses the first form and you don't report any problem with this one. So I don't know. 

DYNCALL(closeDevice());





bigbig a écrit :
> Dear all,
>
> I am testing the USB HID generic AtUsbHid.dll from Atmel in order to build a
> small pc application that can communicate with an ATusb162 through USB
> canal.
>
> Actually I can compile successfully when the functions from AtUsbHid.dll are
> used in the main.c file.
>
> File main.c that compile fine:
> [code]
> /*file main.c */
> #include <stdio.h>
> #include <windows.h>
> #include "AtUsbHid.h"
>
> int main(int arg, char* argv[])
> {
>   HINSTANCE hLib = NULL;
>   hLib = LoadLibrary(AT_USB_HID_DLL);
>   if(loadFuncPointers(hLib)) printf ("loaded");
>   FreeLibrary(hLib);
>   return 0;
> }
> [/code]
>
> The command used was:
> [code]
> g++ -Wall main.c AtUsbHid.dll -o main
> [/code]
> --->>> Until this point it works just fine. :)
>
> Problems arrive when I try to use the functions in another file.
>
> Please have a look at the following:
> The main.c file:
> [code]
> /*file main.c*/
> #include "bidon.h"
> int main(int arg, char* argv[])
> {
>   test();
>   return 0;
> }
> [/code]
> The bidon.h file:
> [code]
> /*file bidon.h*/
> #ifndef _BIDON_H_
> #define _BIDON_H_ 
> #include <stdio.h>
> #include <windows.h>
> #include "AtUsbHid.h"
>
> #define VID 0x03EB
> #define PID 0x2013
>
> extern void test(void);
>
> #endif /*_BIDON_H_*/ 
> [/code]
>
> And the bidon.c file:
> [code]
> /*file: bidon.c*/
> #include "bidon.h"
>
> void test(void)
> {
>   HINSTANCE hLib = NULL;
>   hLib = LoadLibrary(AT_USB_HID_DLL);
>   if(loadFuncPointers(hLib)) printf("\r\nloaded"); 
>   if(DYNCALL(findHidDevice(VID, PID))) printf("\r\nopened");
>   DYNCALL(writeData)((UCHAR *)"11");
>   Sleep(100);
>   DYNCALL(writeData)((UCHAR *)"01");
>   afficher();
>   DYNCALL(closeDevice());
>   FreeLibrary(hLib);
>   printf("\r\nclosed\r\n");
> }
> [/code]
>
> When compiling with:
> [code]
> g++ -Wall main.c bidon.c AtUsbHid.dll -o main
> [/code]
>
> I got the following error:
> [code]
> AtUsbHid.h:107: warning: 'bool loadFuncPointers(HINSTANCE__*)' defined but
> not used
> C:/DOCUME~1/SBIGLE~1.LHT/LOCALS~1/Temp/ccZYEZ1v.o:bidon.c:(.bss+0x0):
> multiple definition of `_lpfindHidDevice'
> C:/DOCUME~1/SBIGLE~1.LHT/LOCALS~1/Temp/ccGROaaE.o:main.c:(.bss+0x0): first
> defined here
> C
> .....
> ...
> ..
> .
> [/code]
>
>
> I would appreciate any comment or advice.
> Thank you for helping.
> Stephane
>
>   


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]