Operating System - HP-UX
1835004 Members
2294 Online
110073 Solutions
New Discussion

Calling C++ from HP Pascal

 
Chris Irwin
New Member

Calling C++ from HP Pascal

I am unclear whether it is possible to call C++ routines from within HP Pascal routines. I need information about doing it the other way around. Is it possible?

I get the error:

/usr/lib/dld.sl: Unresolved symbol: __shlinit (code) from /usr/local/pcm170/lib
pcmsrv.sl

When I run my program...

Any info GREATLY appreciated.

Chris Irwin
coi@cirwin.com
1 REPLY 1
A. Clay Stephenson
Acclaimed Contributor

Re: Calling C++ from HP Pascal

It depends. The most common problems surround global constructors and destructors which depend upon _main(). Look in /opt/aCC/html/C/guide for otherlangs.htm. Here is an excerpt from that file:
---------------
The main() Function

In general, when mixing C++ modules with modules in HP Pascal and HP FORTRAN 90, the overall control of the program must be written in C++. In other words, the main() function must appear in some C++ module and no other outer block should be present.

If you wish to have a main() function in a module other than a C++ module, you can add a call to _main() as the first non-declarative statement in the module. However, if you use this method, your code is not portable.
------------------------


You will find that you will fight far fewer battles if you make a slight change in your thinking. Make what is now you Pascal program a procedure e.g. change
Program My_Program
....
END.

to

Procedure My_Program;
.....
end; {My_Program}

Your then have a small C++ main that calls your Pascal My_Program and you are done. It's far, far easier to link Pascal to C++ than the other way round.


If it ain't broke, I can fix that.