Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 3.78 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to stop GNU GCC from mangling dll import function names
  2. #include <windows.h>
  3.  
  4.    #include <stdio.h>
  5.  
  6.    #include <cstdlib>
  7.  
  8.    #include "dsound.h"
  9.  
  10.    //#include "CGG_Cpp_DInterface.h"
  11.    //The following are relevent items taken from CGG_Cpp_DInterface.h
  12.    struct CrimsonReply1{
  13.    unsigned int Echo;
  14.    unsigned int Result;
  15.    unsigned int ReplyType;
  16.    unsigned int Reserved1;
  17.    unsigned int Reserved2;
  18.    char* OutputString;
  19.    double Reply[32];
  20.    };
  21.  
  22.    extern "C" __declspec(dllimport) int CrimsonCommandProc(/*I'm not going to list all the arguments here*/);
  23.    extern "C" __declspec(dllimport) int TranslateCrimsonReply1(int, CrimsonReply1*, int);
  24.    #define CGG_SETUP               0x20000001
  25.    #define CGG_SHUTDOWN            0x20000005
  26.    #define CGG_WINDOWED            0x0000002F
  27.    #define CGG_RECTANGLE           0x00000024
  28.    #define CGG_STRETCHTOCLIENT     0x00000028
  29.    #define CGG_DUMPALLREPLIES      0
  30.    //End of items taken from CGG_Cpp_DInterface.h
  31.    extern "C" LRESULT CALLBACK WndProc(HWND hWnd, UINT messg, WPARAM wParam, LPARAM lParam );
  32.  
  33.    char szProgName[] = "Age Games:  Animal Reader";
  34.    char message[] = "";
  35.    extern "C"{
  36.  
  37.    int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPreInst, LPSTR lpszCmdLine, int nCmdShow)
  38.    { //Win32 entry-point routine
  39.      MSG WinEvent;//long pointer to an event message sent by Windows to the application
  40.      WNDCLASSEX WinClass;//A Windows Class Struct
  41.      RECT WindowRect;//A structure to describe the position and size of the window.
  42.      HWND WinHand;
  43.  
  44.      /*Other Variables-------------------------------------------------------------*/
  45.      CrimsonReply1 CrimsonReply;
  46.  
  47.  
  48.      /*------------------------------------------------------------------------------
  49.      Set up a window, register it, and create it.
  50.      ------------------------------------------------------------------------------*/
  51.  
  52.      /*set up window class and register it*/
  53.      /*All the standard window initialization is in here.  It's not relevent to the problem.*/
  54.     /*------------------------------------------------------------------------------
  55.     begin the message loop
  56.     ------------------------------------------------------------------------------*/
  57.  
  58.     LPDIRECTSOUND* DirectSoundObject;
  59.     HRESULT Result = DirectSoundCreate(NULL, DirectSoundObject, NULL);
  60.     if (Result == DS_OK && *DirectSoundObject) Result = (*DirectSoundObject)->SetCooperativeLevel(WinHand, DSSCL_NORMAL);
  61.     if (Result != DS_OK) return(0);
  62.     int ReplyPointer = CrimsonCommandProc(CGG_SETUP,NULL,(double)(int)WinHand,NULL,CGG_WINDOWED,NULL,
  63.                               CGG_RECTANGLE,NULL,800,NULL,600,NULL,
  64.                               CGG_STRETCHTOCLIENT);
  65.     if (ReplyPointer) ReplyPointer = TranslateCrimsonReply1(ReplyPointer, &CrimsonReply, CGG_DUMPALLREPLIES);
  66.  
  67.     while(GetMessage(&WinEvent, NULL, 0, 0))
  68.     {
  69.       DispatchMessage(&WinEvent);
  70.     }
  71.     /*------------------------------------------------------------------------------
  72.     Shutdown.
  73.     ------------------------------------------------------------------------------*/
  74.  
  75.     ReplyPointer = CrimsonCommandProc(CGG_SHUTDOWN);
  76.     if (ReplyPointer) ReplyPointer = TranslateCrimsonReply1(ReplyPointer, &CrimsonReply, CGG_DUMPALLREPLIES);
  77.  
  78.     return(WinEvent.wParam);
  79.   } //end of WinMain()
  80.  
  81.   }
  82.        
  83. C:DevelopmentAnimalReaderAnimal Reader.cpp|91|undefined reference to `DirectSoundCreate@12'|
  84.   C:DevelopmentAnimalReaderAnimal Reader.cpp|96|undefined reference to `_imp__CrimsonCommandProc'|
  85.   C:DevelopmentAnimalReaderAnimal Reader.cpp|97|undefined reference to `_imp__TranslateCrimsonReply1'|
  86.   C:DevelopmentAnimalReaderAnimal Reader.cpp|107|undefined reference to `_imp__CrimsonCommandProc'|
  87.   C:DevelopmentAnimalReaderAnimal Reader.cpp|108|undefined reference to `_imp__TranslateCrimsonReply1'|
  88.        
  89. extern HRESULT WINAPI DirectSoundCreate(...);