473,394 Members | 1,878 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,394 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 = [
c_int,
POINTER(c_char_p)
]

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 976

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

Similar topics

2
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...
26
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...
8
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. ...
3
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}
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
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...

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.