Issue using clang parsing in python


I am trying to parse c file using clang. I have created python binding using and passing my .c file as and argument to my python script.

I see that it is not able to parse header file, due to which file linux/errno.h is also not parsed and hence it is not able to get values of macro definition of all error codes.

Not able to parse header files, or not able to FIND (the correct!)
header files? There is a distinct difference... Maybe you could output
the preprocessed data from libclang (using the -E option)


Thanks for your help,

I am passing header files in args option of parse function.

tu = index.parse(sys.argv[1],list_arg)

where list_arg = [’-I/usr/include’,…] --all libraries which i will require.

When I parse .c source file to read all return values of a function using “node2.get_tokens().next().spelling” , it is not able to find correct value of macro which is defined in library included in .c file and passed in args during index.parse().

For Example

static int bcm63xx_wdt_open(struct inode *inode, struct file *file)
if (test_and_set_bit(0, &bcm63xx_wdt_device.inuse))
return -EBUSY; // not able to find value of EBUSY,hence returns error when I try to print node.spelling()
} // EBUSY is defined in linux/errno.h which is included in my .c file and also passed in list_arg.

Thanks again for all your help,
Moiz Ali