[cfe-dev] How to distinguish "int *p" and "int p[]" in function parameters?

John McCall rjmccall at apple.com
Mon Jun 20 11:24:45 PDT 2011


On Jun 20, 2011, at 10:54 AM, Limin FU wrote:
> I started to use clang a few days ago, trying to develop an automated binding tool that can parse C/C++ header files and generate wrapping codes. Now one problem I have is to handle parameter forms "int *p" and "int p[]" differently. But it appears that clang generates pointer type for both. Is there a simple way to distinguish them from their type objects? I really hope I don't have to extract the source codes and parse it myself.
> Thanks a lot,

You want the type as written, i.e. the TypeLoc, which you can get with getTypeSourceInfo()->getTypeLoc().

John.



More information about the cfe-dev mailing list