Lisp HUG Maillist Archive

FLI, passing strings to c functions

Hi,

   I'm building a lisp interface to the HGE
   (http://hge.relishgames.com).

   I get a strange behaviour when trying to set the window title.

   the C++ side
   ------------
   HGESTUB_API void __cdecl
   C_System_SetState_CharPtr(int state, char* value){
        hge->System_SetState(hgeState(state),value);
   }
   
   lisp side
   ---------
   (fli:define-foreign-function
      (hge-system-setstate-charptr "C_System_SetState_CharPtr" :source)
      ((state :int)(value (:reference-pass :ef-mb-string)))
    :calling-convention :cdecl)
   
   the call:
   (hge-system-setstate-charptr HGE_TITLE "Some Title")
  
   When i follow the call with the VC++ debugger the correct string is
   passed to the function, however when the window pops up there's a
   completely different string "C_System_Initiate" in the caption.
   "C_System_Initiate" is the name of an exported function in the dll.

   Any idea how to solve this, it looks like the char pointer passed
   to the C++ function has to be a pointer to static memory, but is
   there a way in lispworks to make a string "static"?
   
-- 
Best regards,
 Steven
www.interstudio.nl

Re: FLI, passing strings to c functions

Unable to parse email body. Email id is 2859

Updated at: 2020-12-10 08:55 UTC