473,473 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Can Python be compiled by a C++ compiler ?

Hi,

having read http://www.python.org/doc/current/ext/ext.html by Guido van
Rossum and Fred Drake,
I got the impression I should compile Python with g++ since section 1.11
indicates that otherwise the constructor of a global or static object
(of an extension in C++) won't be called.

Now trying to build Python (CVS version) with g++ fails. E.g., one
problem is in Parser/pgen.c line 364 with a typical C-like confusion of
types and variables when it declares

ss_arc *ss_arc
where ss_arc is defined by a previous typedef. A C++ compiler won't
accept this.

Do I miss something?

Many thanks for your comments,

Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
Jul 18 '05 #1
2 1367
Helmut Jarausch wrote:
having read http://www.python.org/doc/current/ext/ext.html by Guido
van Rossum and Fred Drake,
I got the impression I should compile Python with g++ since section
1.11 indicates that otherwise the constructor of a global or static
object (of an extension in C++) won't be called.

Now trying to build Python (CVS version) with g++ fails. E.g., one


You'll need to link Python using C++. This is necessary to include the C++
runtime. The individual .c files should be compiled with C.

I believe that using C++ for the link step is even the default choosen by
../configure. Otherwise, extensions such as wxPython wouldn't work out of the
box as they contain code written in C++.

Daniel

Jul 18 '05 #2
At some point, Helmut Jarausch <ja******@skynet.be> wrote:
Hi,

having read http://www.python.org/doc/current/ext/ext.html by Guido
van Rossum and Fred Drake,
I got the impression I should compile Python with g++ since section 1.11
indicates that otherwise the constructor of a global or static object
(of an extension in C++) won't be called.

Now trying to build Python (CVS version) with g++ fails. E.g., one
problem is in Parser/pgen.c line 364 with a typical C-like confusion
of types and variables when it declares

ss_arc *ss_arc
where ss_arc is defined by a previous typedef. A C++ compiler won't
accept this.

Do I miss something?


Yes. Just specify the C++ compiler to the configure script with the
--with-cxx option. My guess it already does this automatically, and
you're just making more work for yourself.

Everything will be compiled with the C compiler (gcc), but will be
linked by the C++ compiler. This assures that the appropiate run-time
stuff needed for C++ extensions is linked in (or something like that),
without actually having to rewrite Python in C++.

--
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
Jul 18 '05 #3

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

Similar topics

467
by: mike420 | last post by:
THE GOOD: 1. pickle 2. simplicity and uniformity 3. big library (bigger would be even better) THE BAD:
58
by: Svein Ove Aas | last post by:
Is anyone working on a python-to-native compiler? I'd be interested in taking a look. Come to think of it, is anyone working on a sexpr-enabled version of Python, or anything similar? I really...
28
by: Maboroshi | last post by:
Hi I am fairly new to programming but not as such that I am a total beginner From what I understand C and C++ are faster languages than Python. Is this because of Pythons ability to operate on...
12
by: Anon | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello all I am a beginner teaching myself python, and I am enjoying it immensely :) As a language it is great, I real treat to study, I actually...
118
by: 63q2o4i02 | last post by:
Hi, I've been thinking about Python vs. Lisp. I've been learning Python the past few months and like it very much. A few years ago I had an AI class where we had to use Lisp, and I absolutely...
852
by: Mark Tarver | last post by:
How do you compare Python to Lisp? What specific advantages do you think that one has over the other? Note I'm not a Python person and I have no axes to grind here. This is just a question for...
7
by: Franz Steinhaeusler | last post by:
Hello, I'm only curious. Why is Python and most extension (also wxPython) not built using an open source compiler like gcc or g++ on Windows? I'm always wondering, why Microsoft is still...
145
by: Dave Parker | last post by:
I've read that one of the design goals of Python was to create an easy- to-use English-like language. That's also one of the design goals of Flaming Thunder at http://www.flamingthunder.com/ ,...
53
by: Vicent Giner | last post by:
Hello. I am new to Python. It seems a very interesting language to me. Its simplicity is very attractive. However, it is usually said that Python is not a compiled but interpreted programming...
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
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.