473,385 Members | 2,269 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.

noddy example, writing C modules for python

Hi,

based on the example module "noddy" i wrote an own one
and i have problems accessing the elements in the python
objects. I defined the example object:

typedef struct {
PyObject_HEAD
int num;
} pmod_obj;
static PyMemberDef pmod_members[] = {
{"number", T_INT, offsetof(pmod_obj, num), 0, /* LINE 143 */
"pmod number"},
{NULL}
};

When i compile this under Win32, i get this (in german):
pmod.cc(143) : error C2552: 'pmod_members': Initialisierung nicht
zusammengesetzter Typen mit Initialisierungsliste ist nicht möglich
'PyMemberDef' : Typen mit benutzerdefinierten Konstruktoren sind
nicht 'aggregate'
pmod.cc(143) : error C2065: 'T_INT': nichtdeklarierter Bezeichner
pmod.cc(143) : error C2275: 'pmod_obj': Ungültige Verwendung dieses Typs als
Ausdruck
pmod.cc(10): Siehe Deklaration von 'pmod_obj'
pmod.cc(143) : error C2065: 'num': nichtdeklarierter Bezeichner
pmod.cc(143) : error C3861: 'offsetof': Bezeichner wurde auch mit einer
argumentbezogenen Suche nicht gefunden
Has anybody got a hint for me? It is not obvious to me why this
does not compile.
Best regards,
Torsten.

Jul 18 '05 #1
3 2491
On Sun, 30 May 2004 11:22:06 +0200, Torsten Mohr <tm***@s.netic.de>
wrote:
pmod.cc(143) : error C2065: 'T_INT': nichtdeklarierter Bezeichner
hmmm, looking at this makes me wonder if you need a:

#include "structmember.h"

since T_INT is defined there.
<{{{*>


Jul 18 '05 #2
> hmmm, looking at this makes me wonder if you need a:

#include "structmember.h"


Hi,

you are right. I did not expect that. I thought that
this would be included from Python.h, but obviously i
was wrong.
Thanks for that hint,
Torsten.

Jul 18 '05 #3
Hi Torsten,

On Sun, 30 May 2004, Torsten Mohr <tm***@s.netic.de> wrote:
based on the example module "noddy" i wrote an own one
and i have problems accessing the elements in the python
objects. I defined the example object: typedef struct {
PyObject_HEAD
int num;
} pmod_obj;
static PyMemberDef pmod_members[] = {
{"number", T_INT, offsetof(pmod_obj, num), 0, /* LINE 143 */
"pmod number"},
{NULL}
};
When i compile this under Win32, i get this (in german):
pmod.cc(143) : error C2552: 'pmod_members': Initialisierung nicht
zusammengesetzter Typen mit Initialisierungsliste ist nicht mglich
'PyMemberDef' : Typen mit benutzerdefinierten Konstruktoren sind
nicht 'aggregate'


The explanation is shown quite clear in plain German - where is your
problem? :-) One is sure: your problem has nothing to do with Python
but with C++. Only for short, look at this example:

#v+
class A {
public:
char *s;
A(): s("") {}
} a = {"Hallo"};
#v-

That cannot compile too because there are two different
initializations: one via constructor and the second via initialization
list. So, of course, Gnu g++ also complains:

test.cc:24: error: `a' must be initialized by constructor, not by `{...}'

HTH & f'up2

Bernd

--
Those who desire to give up freedom in order to gain security,
will not have, nor do they deserve, either one. [T. Jefferson]
Jul 18 '05 #4

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

Similar topics

7
by: Uwe Grauer | last post by:
Hi all, who can help on reading and writing mozilla-mail folders with python? I wanted to implement something like an email-sync for mozilla-mail in python. I did some tests, but something is...
2
by: Xah Lee | last post by:
Python Doc Problem Example: os.system Xah Lee, 2005-09 today i'm trying to use Python to call shell commands. e.g. in Perl something like output=qx(ls) in Python i quickly located the...
20
by: Xah Lee | last post by:
Sort a List Xah Lee, 200510 In this page, we show how to sort a list in Python & Perl and also discuss some math of sort. To sort a list in Python, use the “sort” method. For example: ...
25
by: Xah Lee | last post by:
Python Doc Problem Example: gzip Xah Lee, 20050831 Today i need to use Python to compress/decompress gzip files. Since i've read the official Python tutorial 8 months ago, have spent 30...
7
by: billr | last post by:
but ireally does need clearing up ... Traditionally (i.e. in C++) I might do the following: SomeObj ptrSomeObj; for(int i = 0; i < iCount; ++i) { ptrSomeObj = new SomeObj();...
4
by: John Pote | last post by:
Hello, help/advice appreciated. Background: I am writing some web scripts in python to receive small amounts of data from remote sensors and store the data in a file. 50 to 100 bytes every 5 or...
13
by: gonzlobo | last post by:
Greetings, and happyNewYear to all. I picked up Python a few weeks ago, and have been able to parse large files and process data pretty easily, but I believe my code isn't too efficient. I'm...
3
by: Kinokunya | last post by:
Hi guys, My group and I will be working on our final year project, the scope to do a program/web-based application similar areas of functionalities like the PyLint and PyChecker; a Python syntax...
1
by: Terry Reedy | last post by:
nishalrs wrote: Interesting new applications of Python are welcome. Googling "Python package (or module) ultrasonic sensor" did not turn up anything relevant that I saw. Start with the...
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: 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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.