Solved

How are some pascal functions called in c++

Posted on 1997-03-28
5
441 Views
Last Modified: 2008-03-03
I have an ansi version of C++ and looking for the names of
some functions which I know they're name in pascal but not
in C++.
The functions are :
  GetIntVec/SetIntVec
  Port[] array.
 
0
Comment
Question by:Phoenix020397
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 1

Accepted Solution

by:
white wolf earned 50 total points
ID: 1162502
It's hard to answer your question directly because I don't know your compiler settings, etc.  But I'll try to help out...

First off, to make sure they're compatible, you should tell both C++ and Pascal compilers to use the same "calling convention".
It should be under the compiler options menu or something.
This convention (either "C" or "Pascal") tells the compiler if the parent function is responsible for cleaning up the stack or not...

Now, you have to check both compiler settings again to check if they're automatically prefixing an underscore (or other) character to the name of subroutines.  This should be under the linker menu I think.  If your Pascal compiler doesn't have this "option", you can set the C compiler option to "NO, don't put an underscore" (the C compilers are generally more configurable in this area...)

Also, don't forget to:
1. declare (in the C files) publically the "equivalent" function prototypes of the Pascal procedures/functions it uses.

2. declare (in the interface or public section of Pascal files) the equivalent prototypes of C functions it uses.

To make sure that naming conventions are ok, you can tell both compilers (actually the linkers) to produce detailed MAP files.  These .MAP files produce a listing of the ACTUAL function name and (relative) addresses.  Check the names.

Now, more specific to your problem, remember that a pascal array can be declared as a (char *x) in C/C++.  You may have to play with it if one of your linkers barfs out a "fatal linker error", but otherwise compiles the code.  This fatal error is a sign that the linker can't find the declared function, and can be caused by 3 problems:
1. The function just doesn't exist in any .OBJ file
(that's cause you didn't write it at all!)
2. There's a "parameter type" mis-match.  This is usually the programmer's fault by declaring the function as taking, say, an integer, when the actual code specifies a string (char*), say.
3. the underscore **** is not at the same setting and the (dumb!) linker can't find the function names because one is called, say GetIntVect(?) and the other is _GetIntVect(?).
(the map file will tell you what the actual name is, so check it)

Hope this helps. Also, check out my page for extra info.
I have a doc (written by me) about interfacing pascal and/or C to assembly, that may provide extra details and insight.
Good luck dude!
0
 
LVL 1

Expert Comment

by:white wolf
ID: 1162503
0
 

Author Comment

by:Phoenix020397
ID: 1162504
Those aren't procedures I built in pascal, they are in the DOS unit. There should be such functions in C++ too, but I don't know how to find them.
0
 
LVL 1

Expert Comment

by:white wolf
ID: 1162505
You're kidding, right?  I wrote all that for nothing?!?
OK, for getting/setting interrupt vectors, use
setvect() and getvect() and for port operations, use
inport() (write an "int") and inportb() (write a byte);
outport() and outportb() are the ouput guys.
All are in dos.h...

0
 
LVL 1

Expert Comment

by:white wolf
ID: 1162506
oops...  use inport to read (not write!!!)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question