den-run-ai / ctypesgen

Automatically exported from code.google.com/p/ctypesgen
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Parsing errors with specific #define usage. #50

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hello. 
I am using ctypesgen to generate automatically some python bindings from c.

What steps will reproduce the problem?

This is a simplified version of what my problem is.
1. Consider the following definitions in file file.h.
   #define SIZE(x) sizeof(x)
   #define INT_SIZE SIZE(int)

2. I run:
   ctypesgen.py file.h -o file.py

3. I get an error about parsing the INT_SIZE definition.

What is the expected output? What do you see instead?

The expected output should be a file containing INT_SIZE definition.
The relevant output error is:
WARNING: Could not parse macro "#define INT_SIZE SIZE ( int )"
and the file.py does not contain INT_SIZE.

What version of the product are you using? On what operating system?

I am using the latest (r151) version.
Operating System: Linux Ubuntu 14.04 LTS x64

Please provide any additional information below.

The real problem is similar to the problem described above and occurs when 
file.h contains the following:
   #include <linux/types.h>
   #define CRIOGET         _IOWR('c', 101, __u32)
   //Some other definitions similar to CRIOGET using definitions from  
   //ioctl.h

And run: 
python ctypesgen.py --include=sys/ioctl.h file.h -o file.py

I get the same parsing error.

I used a custom file in python to define those definitions and use 
--insert-file option. But I wonder if this could work without this workaround.

Regards.
Tilemachos.

Original issue reported on code.google.com by tilemach...@gmail.com on 9 Mar 2015 at 1:45