delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/11/17/19:40:05

From: Ian AT kiwiplan DOT co DOT nz (Ian Collins)
Subject: dll argument passing between vb and gcc
17 Nov 1997 19:40:05 -0800 :
Message-ID: <07551A47EAD6D01186430060B025C6F41B6F3A.cygnus.gnu-win32@ntserver.kiwiplan2.co.nz>
Mime-Version: 1.0
To: "'Gnu Mailing list'" <gnu-win32 AT cygnus DOT com>

(Thanks for reply on earlier posting: jeffdbREMOVETHIS AT netzone DOT com. 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
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019