?
Solved

How are some pascal functions called in c++

Posted on 1997-03-28
5
Medium Priority
?
443 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 150 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

770 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