Mixed-Language Programming : Ms-VBDOS v1.00 and Ms-C/C++ v8.00c

D

Danny

Hi all,

I would like to write C++ code and call
it from VBDOS, or even QB 4.5 or PDS 7.1,
including plain-type parameter passing.

My C/C++ compiler is MS-C/C++ v8.00c,
and I have VBDOS v1.00, PDS v7.1,
and QuickBASIC v4.5.

I also have MASM v6.11, if that helps;
when I tried the MASM/VBDOS example,
it worked ok.

I took the C example program from VBDOS's
online Help System, but the C/C++
compiler gave me some error messages.

Could any one please tell me how to
fix this?

Thanks in advance,
Danny.

The files are:
==============

1. STDIO.H - which was present in the same directory.

--------------------------------------------------
2. The C program:
-----------------

#include <stdio.h>

struct common_block { // Structure that looks like the Basic
int a; // common block.
char b[20];
float c;
};

void RCommon(struct common_block far *pointer) {
printf("Element1 = %d\", pointer->a);
printf("Element2 = %Fs\", pointer->b);
printf("Element3 = %f\", pointer->c);
}
--------------------------------------------------
3. The BASIC program:
---------------------

DECLARE SUB RCommon CDECL (_
BYVAL p1o AS INTEGER,_
BYVAL p1s AS INTEGER)

COMMON SHARED element1 AS INTEGER, element2 AS STRING * 20,_
element3 AS SINGLE

element1 = 23
element2 = "DATE : " + DATE$ + CHR$(0)
element3 = 309.03
CALL RCommon(VARPTR(element1), VARSEG(element1))
END

--------------------------------------------------
4. The Command-Line Arguments for the C/C++ Compiler:
-----------------------------------------------------

CL.EXE -c -AM CMODULE.C

--------------------------------------------------
5. The Error Messages given by the C/C++ Compiler:
--------------------------------------------------
cmodule.c
cmodule.c(10) : error C2001: newline in constant
cmodule.c(11) : error C2146: syntax error : missing ')' before identifier 'printf'
cmodule.c(11) : error C2001: newline in constant
cmodule.c(12) : error C2001: newline in constant
 
J

John Harrison

Danny said:
Hi all,

I would like to write C++ code and call
it from VBDOS, or even QB 4.5 or PDS 7.1,
including plain-type parameter passing.

My C/C++ compiler is MS-C/C++ v8.00c,

That compiler is almost prehistoric.
and I have VBDOS v1.00, PDS v7.1,
and QuickBASIC v4.5.

[snip]


void RCommon(struct common_block far *pointer) {
printf("Element1 = %d\", pointer->a);
printf("Element2 = %Fs\", pointer->b);
printf("Element3 = %f\", pointer->c);

Drop the backslashes, don't know why you think you need them

printf("Element1 = %d", pointer->a);
printf("Element2 = %Fs", pointer->b);
printf("Element3 = %f", pointer->c);

Might be an idea to learn some C++ (or C) before going much further,

john
 
K

Kevin Goodsell

Danny said:
Hi all,

I would like to write C++ code and call
it from VBDOS, or even QB 4.5 or PDS 7.1,
including plain-type parameter passing.

This group is for discussion of the C++ language as defined by the
ANSI/ISO C++ Standard. That language does not define any kind of
interface to any other language (except C, sort of). In other words, the
only answer we can give to your question is, "You can't do that in C++."

You could try asking in a group that deals with the tools you are using.

-Kevin
 
S

Stephen Howe

printf("Element1 = %d\", pointer->a);
printf("Element2 = %Fs\", pointer->b);
printf("Element3 = %f\", pointer->c);

Should be something like

printf("Element1 = %d\n", pointer->a);
printf("Element2 = %Fs\n", pointer->b);
printf("Element3 = %f\n", pointer->c);

"\n" is a single character in C and C++ and means newline. The backslash is
the escape character. It means that the 2nd character afterwards is
interpreted differently and the pair of them are 1 character. FYI, a small
table is

\a - alert CHR$(7)
\b - backspace CHR$(8)
\t - tab CHR$(9)
\n - newline CHR$(10)
\v - vertical tab CHR$(11)
\f - form feed CHR$(12)
\r - return CHR$(13)
\\ - single backslash
\" - double quote
\' - single quote

Stephen Howe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top