Comments (3)
Seconding this. I have found a similar issue. Furthermore, if I am attempting to create an unpacked structure, it does not set _pack_ = False
, as it should.
It seems that that clang2py has knowledge of how they are configured in the header file, and ignores it. You get something like:
class myStruct(Structure):
_pack_ = True # source:False
_fields_ = ...
I can only assume what "source:" refers to is the .h file.
from ctypeslib.
Short version: It's the result of the cross-architecture ability of ctypeslib.
My recollection is that pack and alignment are different attributes returned by clang.
In ctypeslib, pack will always be True to ensure that python ctypes fields are actually in the correct index.
If the alignment provided by tells clang says a field is not packed next the the previous one, a Padding field will be inserted in-between.
Given that ctypeslib is aware of multi-architecture issues, it's a requirement.
You just have to trust that the code & alignment, issued for the platform chosen by clang is correct.
You cannot ask a python 2.7 ctypes lib on a x86 arch to know how to pack a structure for a arm 128 arch.
E.g: the python source file can be used on any other system with possibly a different architecture for the python binary, and still work for the targeted arch. You can read x64 memory bytes from x86, and vice-versa.
from ctypeslib.
My understanding is that pack expects an integer number, not a boolean expression (according https://docs.python.org/2/library/ctypes.html#structure-union-alignment-and-byte-order ).
Because Python casts "True" to the integer 1 this works for ctypes library. Setting it to False will lead to a integer of 0 which is not valid
from ctypeslib.
Related Issues (20)
- Multiple errors when trying to use ctypeslib2 instead of ctypeslib HOT 11
- Confusing INFO HOT 1
- What's all about WORD_SIZE, POINTER_SIZE and LONGDOUBLE_SIZE? HOT 1
- Does ctypeslib2 address the same concerns as ctypesgen? HOT 1
- Request: common definitions in separate import
- Request: identify "top level" structs
- Parsing a variadic macro makes clang2py crash HOT 1
- Define with parenthesis not parsed HOT 1
- clang2py not installed in "/usr/bin" HOT 1
- define didn't convert to python HOT 1
- Add if Windows 32bit use WinDLL instead CDLL HOT 1
- Use of "-r" option makes clang2py crash HOT 2
- do not support enum without name HOT 3
- Arithmetic macro not evaluated HOT 1
- _fields_ is final because the structure is used before _fields_ is defined. HOT 1
- Enum wrong generation within included headers HOT 1
- Better union generation
- Fails on variable of enumaterated type
- Can't tell if a char array is const or not
- ran clang2py on a header that had the "raise" symbol HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ctypeslib.