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

Discussion in 'C++' started by Danny, Sep 2, 2003.

  1. Danny

    Danny Guest

    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
     
    Danny, Sep 2, 2003
    #1
    1. Advertising

  2. "Danny" <> wrote in message
    news:...
    > 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
     
    John Harrison, Sep 2, 2003
    #2
    1. Advertising

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

    Danny wrote:

    > 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
    --
    My email address is valid, but changes periodically.
    To contact me please use the address from a recent posting.
     
    Kevin Goodsell, Sep 2, 2003
    #3
  4. Danny

    Stephen Howe Guest

    > 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
     
    Stephen Howe, Sep 2, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Liles
    Replies:
    2
    Views:
    1,770
  2. =?Utf-8?B?QXJuZSBHYXJ2YW5kZXI=?=

    Mixed language programming

    =?Utf-8?B?QXJuZSBHYXJ2YW5kZXI=?=, Mar 29, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,718
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    Mar 29, 2006
  3. =?Utf-8?B?QXJuZSBHYXJ2YW5kZXI=?=

    Mixed language development

    =?Utf-8?B?QXJuZSBHYXJ2YW5kZXI=?=, Apr 3, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    353
    =?Utf-8?B?QXJuZSBHYXJ2YW5kZXI=?=
    Apr 3, 2006
  4. Casey Hawthorne
    Replies:
    4
    Views:
    1,051
    Jarek Zgoda
    Aug 4, 2006
  5. Guch
    Replies:
    3
    Views:
    325
    Guch Wu
    Mar 27, 2006
Loading...

Share This Page