Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling C1.52 library from DOS pascal 3.31

Status
Not open for further replies.

oscillogoat

Programmer
Dec 20, 2004
7
0
0
US
I am trying to call the mmsystem library that comes from VC 1.52 from MS-DOS pascal 3.31. I am Using the waveInGetNumDevs to test with.
function waveInGetNumDevs:NumDevs:word; extern;
result:= waveInGetNumDevs;
The source compiles and successfully links but sends control back to Windows and gives the error "The program has performed an illegal operation and will be shut down."
When I use the lines
function waveInGetNumDevs:NumDevs:word; extern;
result:= waveInGetNumDevs;
and it compiles but I get the link error
L2029 '_waveingetnumdevs' unresolved external
waveInGetNumDevs is described as function UINT
I have also tried the above with pascal integer type instead of word.

Anybody got any ideas?
 
I don't know about your particular compilers, but Pascal and C tend to use slightly different code at the start and end of functions to handle the call. I'd almost expect you to end up with a messed up stack and a return into nowhere. This is probably a prime case for choosing one language or the other, or getting into the depths of assembly and handling of calls in high level languages.
 
The Pascal 3.31 manual says you can do mixed language programming. I think the problem may be either calling C++ 1.52 (windows) from Pascal 3.31(DOS) or that my variable types are not matched.
I am willing to use assembly if necessary but would rather avoid it. I was hopping someone had actualy called C++ 1.52 from Pascal 3.31. In the mean time, I am going to see if I can call C++ 1.52 code that I have compiled from Pascal 3.31.
 
Is that true for windows 95 calls from DOS?
Can I call DOS from windows 95?
 
You are able to call DOS functions from Windows via the shell (command.com). Vice versa is not possible as far as I know.

But try out FreePascal. The environment and feel is much like ye good olde Turbo Pascal!

Or even better - if you feel up to it, go all the way : Delphi .... c",) Here's a trial version:


Regards


Jakob
 
How are the graphics on freepascal and delphi?
I use a lot of graphics primitives like setviewport, and setworld as well as graphics text.
 
Delphi is a windows developemt pascal language. To what you need go for FreePascal -it supports simplistic graphics like you want (viewport etc.)

Regards


Jakob
 
Thanks All.

I installed free pascal and have been converting the graphics today. I will start a new thread if I get stuck on the conversion.
 
Did Not have much luck with free pascal. My program does a lot of bitwise graphics. I wanted to explore using vc++ 1.52 as the parrant and breaking up my dos pascal into modules.

I can compile the C++ code and the dos pascal module but I get an unresolved external maxparam error when I Link the object code.
FOR AN EXAMPLE PROTOTYPE
The C++ code has the lines
void __pascal maxparam(int __near * a, int __near * b);
main()
{
int a:=5;
int b:=7;
maxparam(&a,&b);
}

and the pascal has the lines

MODULE Psub;
PROCEDURE Maxparam (VAR a INTEGER; VAR b:integer);
BEGIN
IF a> b then
b:=a;
ELSE
a:=b;
END;
END.

I have tried making psub a static library and have also tried psub as an import file.

ANY IDEAS ON LINKING
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top