Board index » delphi » Delphi and C-compilers

Delphi and C-compilers

At the moment I'm trying to get Delphi DLL's to work with the C-compiler
Labwindows/CVI. The DLL contains procedures, that simply return the value
they are called with (in another variable). This works OK for integers,
doubles, booleans, and words, but strings don't work.

I'm already using the Pchar type, but that doesn't seem to solve the
problem. I'm still getting a General Protection Fault.

Here is the code i'm using. Can anyone tell me what is wrong?

Pascal def:        
  Procedure  GetString(var s:Pchar);
  begin
    StrPCopy(s,'123456abcdefg..z');
  end;

C-header

    void GetString(char * s);

LWCVI call
   char * s;
   GetString(s);  <-- here happens the General prot. fault
   printf ("s was %s\n");

Thanx in advance

                Arnold Huibregtse
                huibregtse...@cft.philips.nl

 

Re:Delphi and C-compilers


On 26 Feb 1997 08:44:18 GMT, "Arnold Huibregtse"

Quote
<huibregtse...@cft.philips.nl> wrote:
>At the moment I'm trying to get Delphi DLL's to work with the C-compiler
>Labwindows/CVI. The DLL contains procedures, that simply return the value
>they are called with (in another variable). This works OK for integers,
>doubles, booleans, and words, but strings don't work.

>I'm already using the Pchar type, but that doesn't seem to solve the
>problem. I'm still getting a General Protection Fault.

>Here is the code i'm using. Can anyone tell me what is wrong?

>Pascal def:        
>  Procedure  GetString(var s:Pchar);
>  begin
>    StrPCopy(s,'123456abcdefg..z');
>  end;

>C-header

>    void GetString(char * s);

>LWCVI call
>   char * s;

Here, You have not alloc memory for s. you should use s =
malloc(MAXLength); first.

- Show quoted text -

Quote
>   GetString(s);  <-- here happens the General prot. fault
>   printf ("s was %s\n");

>Thanx in advance

>            Arnold Huibregtse
>            huibregtse...@cft.philips.nl

Other Threads