473,385 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Calling Pascal from C++ and Vice Versa

I am tying to call a Pascal function from C++, and vice versa.

Does anyone know how to do this, or where detailed information on this topic
can be found?

For the C++ to Pascal call I have tried declaring the Pascal function as:-

extern "C" void PASCALTESTFUNC1();

within my C++ code. However, the linker is giving me an unresolved
reference, even though I have a Pascal object file with a Pascal procedure
called PASCALTESTFUNC1.

extern "Pascal" doesn't compile.

Any comments or pointers will be appreciated.

I'm running on SuSE Linux 9.0, using GNU g++ for compiling C++, and the fpc
Free Pascal compiler for Pascal.

--
Chris Gordon-Smith
London
Homepage: http://graffiti.virgin.net/c.gordon-smith/
Email Address: Please see my Home Page
Jul 22 '05 #1
4 4323
"Chris Gordon-Smith" <us*********@myhomepage.net> wrote...
I am tying to call a Pascal function from C++, and vice versa.

Does anyone know how to do this, or where detailed information on this topic can be found?
Multi-language programming is compiler-specific. You should look in
your compiler manual about the availability and recommendations on how
to do that.

For the C++ to Pascal call I have tried declaring the Pascal function as:-

extern "C" void PASCALTESTFUNC1();
Why? Shouldn't it at least be

extern "Pascal"

??

within my C++ code. However, the linker is giving me an unresolved
reference, even though I have a Pascal object file with a Pascal procedure
called PASCALTESTFUNC1.

extern "Pascal" doesn't compile.


That means that your compiler doesn't support it, most likely.

Victor
Jul 22 '05 #2
Chris Gordon-Smith wrote in
news:bu************@ID-167468.news.uni-berlin.de:
I am tying to call a Pascal function from C++, and vice versa.

Does anyone know how to do this, or where detailed information on this
topic can be found?

For the C++ to Pascal call I have tried declaring the Pascal function
as:-

extern "C" void PASCALTESTFUNC1();

within my C++ code. However, the linker is giving me an unresolved
reference, even though I have a Pascal object file with a Pascal
procedure called PASCALTESTFUNC1.

extern "Pascal" doesn't compile.

Any comments or pointers will be appreciated.

I'm running on SuSE Linux 9.0, using GNU g++ for compiling C++, and
the fpc Free Pascal compiler for Pascal.


You'll need to ask this in a forum thats about the tools your using.

The language doesn't define any way in which stuff compiled with
any other tool can be linked. Shuch things are only defined by the
tool vendors (implementors).

I'd start by asking in an fpc newsgroup/forum (if there is such a
thing), otherwise try a gcc newsgroup (news://gnu.gcc.help IIRC) or
a linux/SuSE newsgroup/forum.

HTH.

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #3

"Chris Gordon-Smith" <us*********@myhomepage.net> wrote in message
news:bu************@ID-167468.news.uni-berlin.de...
I am tying to call a Pascal function from C++, and vice versa.

Does anyone know how to do this, or where detailed information on this topic can be found?

For the C++ to Pascal call I have tried declaring the Pascal function as:-

extern "C" void PASCALTESTFUNC1();

within my C++ code. However, the linker is giving me an unresolved
reference, even though I have a Pascal object file with a Pascal procedure
called PASCALTESTFUNC1.

extern "Pascal" doesn't compile.


You almost certainly want to look at your pascal compiler documentation
which will probably tell you how to link to C.
C is the common interface for many programming languages.
Jul 22 '05 #4
The parameter passing convention in pascal is different from C++.
In C++ code, the calling function is responsible for removing the function
parameters from the stack.

In Pascal code, the called function removed the parameters from the stack.

You might be able to write an assembly wrapper to fix this. I think
in the Windows environment you might get direct Pascal support as
some code in Windows/MS Office was originally written in Pascal.

Sandeep
--
http://www.EventHelix.com/EventStudio
EventStudio 2.0 - System Architecture Design CASE Tool
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Kyler Laird | last post by:
I need to submit C/C++ code for a class. (It's not a programming class. The choice of language is inertial. I think that it mostly serves to distract students from the course subject.) I'm...
1
by: Dharmendra Singh | last post by:
Hi I'm using .Net(C#) and working on the form(Screen) which have text boxes for both arabic and english data to store. So i want to change the language at run time from arabic to english and...
7
by: Klaus Friese | last post by:
Hi, i'm currently working on a plugin for Adobe InDesign and i have some problems with that. I'm not really a c++ guru, maybe somebody here has an idea how to solve this. The plugin is...
5
by: Protoman | last post by:
How do I call assembly code from C++ code and vice versa? Thanks for the help!!!
6
by: jalkadir | last post by:
Let's say that I have this class: class Parent{ private: char* str; public: const char* getStr(){return str;} }; And then I create a child class class Child{ private: std::string str;...
2
by: Steve - DND | last post by:
Just wondering if anyone out there has any code to convert a plural word to it's singular form and vice versa. Most of our database tables are named in a plural fashion. When we go to create...
0
by: Aziz Paracha | last post by:
Hi: I am very new to .NET web services. I have a situation here; I want a web service that will communicate with plain ASP page. It will call ASP page with some query string variables, the ASP...
6
by: myname | last post by:
i need help with referencing variables from php to a javascript or vice versa. my pages are written in php primarily. i needed a user response - therefore i used javascript and used confirm() to...
1
by: Maric Michaud | last post by:
Le Tuesday 24 June 2008 07:08:46 swapna mudavath, vous avez écrit : This is not valid xml, there is no commas in attribute list in xml. You could try with minidom if your xml stream isn't too...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.