problem compiling code

This is a discussion on problem compiling code within the C Programming forums, part of the General Programming Boards category; im trying to get my phidgets reader to read my rfid tag but for some reason, i cannot figure out, ...

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    2

    problem compiling code

    im trying to get my phidgets reader to read my rfid tag but for some reason, i cannot figure out, it wont compile.

    here is my code
    Code:
    int __stdcall RFID_Handler(CPhidgetRFIDHandle RFID, void *userptr, 
    unsigned char *buf)
    {
       wsprintf(rfId,L"%x%x%x%x%x%x%x%x%x%x\n", 
    buf[0]/16,buf[0]%16,buf[1]/16,buf[1]%16, buf[2]/16,buf[2]%16, 
    buf[3]/16,buf[3]%16, buf[4]/16,buf[4]%16);
       result = 1;
       return 0;
    }
    
    // This is our entrypoint, where the PollGina calls us
    POLLIB_API void pollFunction(LPTSTR loginUsername,LPTSTR 
    loginPassword,LPTSTR loginDomain) {
       WCHAR *username = NULL, *password = NULL, *domain = NULL;
    
       CPhidgetRFIDHandle RFID = 0;
       CPhidgetRFID_create(&RFID);
       
       CPhidget_set_OnAttach_Handler((CPhidgetHandle)RFID, 
    RFID_AttachHandler, NULL);
       CPhidget_set_OnDetach_Handler((CPhidgetHandle)RFID, 
    RFID_DetachHandler, NULL);
       CPhidget_set_OnError_Handler((CPhidgetHandle)RFID, 
    RFID_ErrorHandler, NULL);
       CPhidget_open ((CPhidgetHandle)RFID, -1);
       
       // Clear any existing rfid data
       memset(rfId,0,sizeof(rfId));
    
       CPhidgetRFID_setAntennaOn(RFID, true);
       
       // Set the callback for read events
       CPhidgetRFID_set_OnTag_Handler(RFID, RFID_Handler, NULL);
       
       // Set the output state to 3
       CPhidgetRFID_setOutputState(RFID, 3, true);
       //CPhidgetRFID_setLEDOn(RFID, true);
    
       usleep (100);
       //while (1)
       //{
       //   if (result) break;
       //}
    
          // If an id was read
          if(_tcslen(rfId)) {
          // And it does NOT match the last used one
             if(lastUsed) {
                if(wcscmp(rfId,lastUsed) == 0) {
                   // This is the same one as last time, ignore it
                   goto cleanup;
                }
             }
    
             // Strip trailing \n that phidgets puts in...
             if(wcsstr(rfId,L"\n")) {
                *(wcsstr(rfId,L"\n")) = '\0';
             }
          
             username = AnsiToUnicode("DennisYan");
             password = AnsiToUnicode("dennisbar");
             domain = AnsiToUnicode("");
          
          // Username is required, the rest are optional, put the data in 
    the buffers provided by PollGina
             if(username) {
             wsprintf(loginUsername,L"%s",username);
          
                if(password) {
                   wsprintf(loginPassword,L"%s",password);
                }
                if(domain) {
                   wsprintf(loginDomain,L"%s",domain);
                }
             }   
          }
    
          // Cleanup after ourselves.. free memory we've allocated, and 
    leave
       cleanup:
          if(username) {
             free(username);
             username = NULL;
          }
          if(password) {
             free(password);
             password = NULL;
          }
          if(domain) {
             free(domain);
             domain = NULL;
          }
       
       // Close the reader
       CPhidget_close ((CPhidgetHandle)RFID);
    
       // Delete our context
       CPhidget_delete((CPhidgetHandle )RFID);
    }
    then i compile with

    g++ test2.cpp -lphidget20 -o test2

    all i get is this error

    test2.cpp:1: error: expected initializer before ‘RFID_Handler’
    test2.cpp:12: error: expected constructor, destructor, or type conversion before ‘void’



    any help is appreciated, thanks
    Last edited by Salem; 06-20-2007 at 03:29 PM. Reason: Remove colour from code

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,236
    Your compiler doesn't know what __stdcall and POLLIB_API are. What compiler are you using?

  3. #3
    Registered User
    Join Date
    Jun 2007
    Posts
    2
    Quote Originally Posted by brewbuck View Post
    Your compiler doesn't know what __stdcall and POLLIB_API are. What compiler are you using?
    GCC, GNU compiler

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    Well the sensible place to ask the question would have been here
    http://www.phidgets.com/modules.php?...BB2&file=index
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems with compiling code in cygwin
    By firyace in forum C++ Programming
    Replies: 4
    Last Post: 06-01-2007, 08:16 AM
  2. code problem
    By maritos in forum C Programming
    Replies: 1
    Last Post: 11-27-2005, 04:22 PM
  3. Problem compiling GMP code
    By Bruno Couto in forum C Programming
    Replies: 2
    Last Post: 10-08-2005, 04:37 PM
  4. problem with selection code
    By DavidP in forum Game Programming
    Replies: 1
    Last Post: 06-14-2004, 01:05 PM
  5. Problem : Threads WILL NOT DIE!!
    By hanhao in forum C++ Programming
    Replies: 2
    Last Post: 04-16-2004, 01:37 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21