Comments (2)
Not really,
the clang preprocessor should be doing it, not ctypeslib.
from ctypeslib.
Okay. Just to make sure I described my issue clearly, I am only encountering a problem when I use the -k m
option to include macros in the ctypeslib output. I am passing in a .h file to define constants and structure typedefs. If I include a multi-line macro in the .h file containing part of a structure definition, I can use that macro within structure typedefs in the .h file, and ctypeslib will process the macro correctly as long as I do not use the -k m
option (I am guessing this is because the clang preprocessor is handling the macros in this case). If I use the -k m
option I get the following error:
$ python3 "ctypeslib\clang2py.py" -c -k cdefmstu -o message_defs.py message_defs.h
Traceback (most recent call last):
File "ctypeslib\clang2py.py", line 311, in <module>
main()
File "ctypeslib\clang2py.py", line 306, in main
flags=clang_opts)
File "ctypeslib\codegen\codegenerator.py", line 888, in generate_code
parser.parse(srcfile)
File "ctypeslib\codegen\clangparser.py", line 120, in parse
self.startElement(node)
File "ctypeslib\codegen\clangparser.py", line 159, in startElement
stop_recurse = self.parse_cursor(node)
File "ctypeslib\codegen\clangparser.py", line 273, in parse_cursor
return self.cursorkind_handler.parse_cursor(cursor)
File "ctypeslib\codegen\cursorhandler.py", line 37, in parse_cursor
return mth(cursor)
File "ctypeslib\codegen\util.py", line 119, in fn
return func(*args, **kwargs)
File "ctypeslib\codegen\cursorhandler.py", line 1041, in MACRO_DEFINITION
tokens = self._literal_handling(cursor)
File "ctypeslib\codegen\util.py", line 119, in fn
return func(*args, **kwargs)
File "ctypeslib\codegen\cursorhandler.py", line 528, in _literal_handling
value = self.get_registered(value).body
File "ctypeslib\codegen\handler.py", line 47, in get_registered
return self.parser.get_registered(name)
File "ctypeslib\codegen\clangparser.py", line 188, in get_registered
return self.all[name]
KeyError: 'msg_type'
Here is the example message_defs.h file that causes this error:
#define MT_REQUEST_TEST_DATA 101
#define MT_TEST_DATA 102
#define RTMA_MSG_HEADER_FIELDS \
int msg_type; \
int msg_count; \
double send_time; \
double recv_time
typedef struct
{
RTMA_MSG_HEADER_FIELDS;
int a;
int b;
double x;
} MDF_TEST_DATA;
I had been assuming the issue was related to reading in one line at a time, but I tried redefining the macro on a single line like this, and got the same error: #define RTMA_MSG_HEADER_FIELDS int msg_type; int msg_count; double send_time; double recv_time
Does the -k m
option rely on the clang preprocessor in the same way as when -k m
is not specified?
Thanks.
from ctypeslib.
Related Issues (20)
- 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
- Nested named structs names are not detected. HOT 8
- No output from clang2py even for simple headers - CLANG compatibility issues HOT 6
- ctypeslib2 gives following error on any anaconda environment whenever installed with pip. HOT 3
- AttributeError: 'Output' object has no attribute 'options' HOT 1
- clang dependecy issue in version 2.3.2 (ubuntu 20.04) HOT 6
- Macro values with parenthesis are not converted HOT 2
- File format has no dynamic symbol table HOT 1
- get_version() access violation on clang 17.0.2 HOT 2
- C++ interface HOT 1
- Add __slots__ to structs HOT 1
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.