xoofx/CppAst.NET

CppParserOptions.ParseMacros null reference using windows headers

amerkoleci opened this issue · 2 comments

Hi,
I'm trying to parse windows headers (d3d11.h) in this case and if I set ParseMacros to true it crashes internally with NullReferenceException.

var sdkPath = @"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um";
            var options = new CppParserOptions
            {
                ParseMacros = true,
            };
            options.SystemIncludeFolders.Add(sdkPath);
            var headerFile = "d3d11.h";
            var compilation = CppParser.ParseFile(Path.Combine(sdkPath, headerFile), options); /* Crash here */

StackTrace:

   at CppAst.CppModelBuilder.ParseMacro(CXCursor cursor)
   at CppAst.CppModelBuilder.VisitMember(CXCursor cursor, CXCursor parent, CXClientData data)
   at CppAst.CppModelBuilder.VisitTranslationUnit(CXCursor cursor, CXCursor parent, CXClientData data)
   at ClangSharp.clang.visitChildren(CXCursor parent, CXCursorVisitor visitor, CXClientData client_data)
   at CppAst.CppParser.ParseInternal(List`1 cppFiles, CppParserOptions options)
   at CppAst.CppParser.ParseFiles(List`1 cppFilenameList, CppParserOptions options)
   at CppAst.CppParser.ParseFile(String cppFilename, CppParserOptions options)
   at ConsoleApp2.Program.Main(String[] args) in C:\Test\Program.cs:line 45

Any thought?

xoofx commented

No idea, It requires debugging, if you can investigate.

I'd check out https://github.com/microsoft/CsWinRT

That should give you the CS API access for the windows types you're looking for