473,385 Members | 1,798 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.

ctypes help for "array of character pointers" as an output parameter

I'm wrapping a C function exists in a shared library. Its prototype
looks like as follows

int getFileNames(int aSize, char **names);

The documentation says that the asSize is the number of entries to be
returned and
names is output array of character pointers of at least aSize
elements. So, I defined
a function prototype in python, follow ctypes tutorial, and try to run
it. The following
code section shows what I did.

_getNames = TheLib.getNames
_getNames.restype = c_int
_getNames.argtypes = [

def getNames():
aSize = 1024
names = (c_char_p * arraySize)()
rc = _getNames(aSize, names)

After that, I make a call to getNames() in my python program and,
unfortunately, either TypeError
or Segmentation fault. Sigh...

I wonder that whether the _getNames prototype definition in my code
section is correct??
If it isn't, I guess so, how do I do a right one?
Another, whether the usage in getNames() is correct??
Appreciate for any reply or recommendation.

Jun 23 '07 #1
0 974

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

Similar topics

by: Simon Morgan | last post by:
I hope this isn't OT, I looked for a newsgroup dealing purely with algorithms but none were to be found and seeing as I'm trying to implement this in C I thought this would be the best place. I...
by: drako | last post by:
Hi, I'm a bit stumped as I am getting a "Notice: Array to String Conversion" error when trying to do something that on the surface should be a very simple task - create an array, and write a set...
by: arnuld | last post by:
i have created a solutions myself. it compiles without any trouble and runs but it prints some strange characters. i am not able to find where is the trouble. ...
by: Jess | last post by:
Hello, If I have a constant array, i.e. it's elements aren't changed, should I declare it as: const int a = {1,2,3}; or int const a = {1,2,3}
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,...
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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,...
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: 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.