Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Article Q27301
◄Contents► ◄Index► ◄Back►
─────────────────────────────────────────────────────────────────────────────
◄Knowledge Base Contents► ◄Knowledge Base Index►
Passing Basic User-Defined Type to C by Far Reference - Q27301
The following example demonstrates how to pass a user-defined type
from compiled Basic to Microsoft C by far reference.
This information applies to the Standard and Professional Editions of
Microsoft Visual Basic version 1.0 for MS-DOS and to Microsoft C
Compiler version 7.0.
To compile this example in Visual Basic for MS-DOS, execute the
following commands:
BC BMODULE.BAS;
CL -c -AM CMODULE.C
LINK BMODULE.OBJ CMODULE.OBJ;
Basic Program
-------------
TYPE record
a AS INTEGER
b AS STRING * 20
c AS SINGLE
END TYPE
DECLARE SUB TypeReference CDECL (BYVAL p1o AS INTEGER, _
BYVAL p1s AS INTEGER)
CLS
DIM element AS record
element.a = 128
element.b = DATE$ + CHR$(0)
element.c = 39.6
CALL TypeReference(VARPTR(element), VARSEG(element))
LOCATE 4, 1
END
C Routine
---------
#include <stdio.h>
struct record {
int a;
char b[20];
float c;
};
void TypeReference(struct record far *element) {
printf("Record.A = %d\", element->a);
printf("Record.B = %s\", element->b);
printf("Record.C = %f\", element->c);
}
Output
------
Record.A = 128
Record.B = 02-02-1988
Record.C = 39.599998