Description
Brief Description
I am attempting to use CppSharp to generate C# bindings for https://github.com/apache/arrow/blob/master/cpp/src/arrow/api.h. However, I am getting a NRE coming from CppTypePrinter.VisitPointerType
.
From debugging CppSharp, I narrowed it down to the following code:
CppSharp/src/Generator/Generators/C/CppTypePrinter.cs
Lines 94 to 97 in 0b825e1
In this case, pointee
on line 95
is null
. This is because pointer.Pointee
is null above it.
Doing some more digging, I found that it looks like the PointerType
it is trying to visit is coming from the vendored/variant.hpp
header file. You can see the file, and code, that is causing the problem here:
I can repro the NRE by just trying to generate code for that vendored/variant.hpp
file. That variant.hpp file appears to be coming from https://github.com/mpark/variant.
OS: Windows 10
Used headers
Used settings
public void Setup(Driver driver)
{
driver.Options.GeneratorKind = GeneratorKind.CSharp;
//driver.Options.GenerateInternalImports = true;
var module = driver.Options.AddModule("Sample");
module.IncludeDirs.Add(@"C:\temp\pyarrow\include\");
//module.Headers.Add(@"arrow\vendored\variant.hpp");
module.Headers.Add(@"arrow\api.h");
module.LibraryDirs.Add(@"C:\temp\pyarrow");
module.Defines.Add("WIN32");
module.Defines.Add("_WINDOWS");
module.Defines.Add("NDEBUG");
module.Libraries.Add("arrow.dll");
}
Target: MSVC/GCC/Clang
Other settings
Stack trace or incompilable generated code
Parsed 'arrow\api.h'
Processing code...
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at CppSharp.Generators.C.CppTypePrinter.VisitPointerType(PointerType pointer, TypeQualifiers quals)
at CppSharp.AST.PointerType.Visit[T](ITypeVisitor`1 visitor, TypeQualifiers quals)
at CppSharp.Types.TypeMapDatabase.FindTypeMap(Type type, TypeMap& typeMap)
at CppSharp.Passes.CheckIgnoredDeclsPass.IsTypeComplete(Type type)
at CppSharp.Passes.CheckIgnoredDeclsPass.HasInvalidType(Type type, Declaration decl, String& msg)
at CppSharp.Passes.CheckIgnoredDeclsPass.VisitFunctionDecl(Function function)
at CppSharp.AST.AstVisitor.VisitMethodDecl(Method method)
at CppSharp.Passes.CheckIgnoredDeclsPass.VisitMethodDecl(Method method)
at CppSharp.AST.AstVisitor.VisitClassDecl(Class class)
at CppSharp.Passes.CheckIgnoredDeclsPass.VisitClassDecl(Class class)
at CppSharp.AST.Class.Visit[T](IDeclVisitor`1 visitor)
at CppSharp.AST.AstVisitor.VisitDeclarationContext(DeclarationContext context)
at CppSharp.AST.AstVisitor.VisitNamespace(Namespace namespace)
at CppSharp.AST.Namespace.Visit[T](IDeclVisitor`1 visitor)
at CppSharp.AST.AstVisitor.VisitDeclarationContext(DeclarationContext context)
at CppSharp.AST.AstVisitor.VisitNamespace(Namespace namespace)
at CppSharp.AST.Namespace.Visit[T](IDeclVisitor`1 visitor)
at CppSharp.AST.AstVisitor.VisitDeclarationContext(DeclarationContext context)
at CppSharp.Passes.TranslationUnitPass.VisitTranslationUnit(TranslationUnit unit)
at CppSharp.Passes.TranslationUnitPass.VisitASTContext(ASTContext context)
at CppSharp.Passes.CheckIgnoredDeclsPass.VisitASTContext(ASTContext c)
at CppSharp.Generators.BindingContext.<RunPasses>b__29_0(TranslationUnitPass pass)
at CppSharp.PassBuilder`1.RunPasses(Action`1 action)
at CppSharp.Generators.BindingContext.RunPasses()
at CppSharp.Driver.ProcessCode()
at CppSharp.ConsoleDriver.Run(ILibrary library)
at PlasmaGenerator.Program.Main(String[] args)