473,398 Members | 2,403 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,398 software developers and data experts.

SWIG + print value of pointer

I am using SWIG to wrap a C application for use in Python.

C code
======
// returns a pointer to an array of long values in the string, "input"
// MY_DIGIT is a typedef such as, typedef unsigned long MY_DIGIT;
MY_DIGIT *Split(char *input) { ... }

...I build a DLL named, _MyApp.dll

SWIG interface
==============
%module MyApp
extern MY_DIGIT *Split(char *input, char *delimiters);

%include cpointer.i
%pointer_functions(MY_DIGIT, md_ptr);

Python
=============
from MyApp import *
msg = "5,7,1,0,4,6,9"
delims = ","
results = Split(msg, delims)
str(results) '_401ba700_p_MY_DIGIT' repr(results) '<Swig Object at _401ba700_p_MY_DIGIT>' print results


....when I print "results" python.exe crashes

....any idea why it crashes? Why can't I print it? FYI, if it matters,
I do the same steps in the main method of my C code and there is no
problem.

thanks.

Oct 7 '05 #1
0 1259

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

Similar topics

3
by: kj.kjn | last post by:
My function func(File * des) is embedded in a module swig. I would to know how to call this function from python script and if it's necessay to declare a typemaps ? Thank you
0
by: Jeff | last post by:
I'm trying to pass a proxy class instance (SWIG generated) of CClass, to a python callback function from C++. The proxy class instance of CClass is created from a pointer to the C++ class CClass....
0
by: James Carroll | last post by:
Hi, I asked this on the SWIG mailing list, but it's pretty dead over there.... I'm trying to get Python to pass a subclass of a C++ object to another C++ object... I have three C++ classes, ...
2
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
0
by: Shankar | last post by:
Hello, I have a C++ dll with one class which has one public function. This function returns an std::list<std::wstring> as an argout. I am using SWIG to generate Python extensions for this dll. ...
1
by: cody314 | last post by:
Versions: Python 2.5.1 (r251:54863, May 14 2007, 10:50:04) SWIG Version 1.3.20 Hello I have some code that wraps a C++ library so I may use it in python. The code basically just gets some data...
2
by: mk | last post by:
Hello, I'm having terrible problems building C++ extension to Python 2.4 using SWIG. I'd appreciate if somebody knowledgeable at the subject took a look at it. swig-1.3.29, g++ (GCC) 4.1.1...
5
by: emmanuel.rivoire | last post by:
Hello, I spent almost a week to be able to embed Python within my C++ game engine. I wrote a mini-tutorial of what I was able to do so far here :...
2
by: Sells, Fred | last post by:
Diez wrote... You're right the ctypes does seem more pythonesque; however I'm still stuck trying return all these parameters that the c api uses. my ctypes code is below. It just quits running...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.