xoofx / CppAst.NET

CppAst is a .NET library providing a C/C++ parser for header files powered by Clang/libclang with access to the full AST, comments and macros
BSD 2-Clause "Simplified" License
482 stars 63 forks source link

how to check for exact CppType in the compilation? #46

Closed danyhm closed 3 years ago

danyhm commented 3 years ago

Hello,

this seems like a newbie question however I can't seem to find a way to check for the exact CppType in any location.

suppose I have a function and the return type is "Unsigned int"

the function.ReturnType is CppType and that Cpptype is an abstract class that based on the type other classed implement it like CppPrimitiveType etc.

my question is that In the VS2019 debugger I can see that the "Kind" field is there however it's not public and I don't want to use reflection to get the value. how can I know which primitive type I'm dealing with? like how can I compare it with CppPrimitiveType members or CppPrimitiveKind members to see exactly what primitive that is?

danyhm commented 3 years ago

Never mind i found it.

for anyone else having this issue. you should check the TypeKind and based on that cast the obj to appropriate subclass