Subject: dll argument passing between vb and gcc
From: [email-masked] (Ian Collins)

17 Nov 1997 19:40:05 -0800
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain
To: "'Gnu Mailing list'" <[email-masked]>

(Thanks for reply on earlier posting: [email-masked]. It
worked).

I am trying to get vb5 talking to a dll created by gcc under gnu-win32
(It's not a case of want to, but have to).

Integer passing works fine. An int in gcc is a long in vb.

String (char*) and double (float) passing is interesting however, and I
wonder if anyone has done it or can point me in the right direction.

Take for example the following examples,

Example 1: getting floating point number between vb and the dll.

In the gcc dll,

float floatvalby2(i)
     float i;
{
  return i*2;
}

The vb caller is,
    Private Declare Function floatvalby2 Lib "e:\usr3\ian\myc" (ByVal f
As Double) As Double
    Dim myf1 As Double
    Dim myf2 As Double
    myf1 = 123.1
    myf2 = floatvalby2(myf1)

This gives me a suitably cryptic "Expression too complicated error" on
execution of the vb floatvalby2 call.

Example 2: getting character strings between vb and the dll.

In the gcc dll,

void subbackstr (str)
  char *str;
{
  strcpy(str, "This is a string");
}

The vb caller is,

Private Declare Sub subbackstr Lib "e:\usr3\ian\myc" (ByRef instr As
String)
dim str as string
str = "This is the initial string"
Call subbackstr(str)

This dumps vb with a dr watson.
(I have also tried allocating the memory from the heap in the gcc
routine and returning the required string as a function, 
which also gives the same result).

(and people say Unix is complicated!)
Ian Collins. 
KIWIPLAN NZ.

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".