Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cxxnew does not work with constructor arguments #478

Open
TomasOberhuber opened this issue Jul 27, 2020 · 0 comments
Open

cxxnew does not work with constructor arguments #478

TomasOberhuber opened this issue Jul 27, 2020 · 0 comments

Comments

@TomasOberhuber
Copy link

Hi,

I am new in Julia so I hope I am not doing some kind of stupid mistake. However, what is wrong with this example?

using Cxx

cxx"""
#include <string>

std::string s( "123" );
"""

function testCxx()
   std_str = @cxxnew std::string( "123" )
end

testCxx()

The output is as follows:

ERROR: LoadError: Got bad type information while compiling Cxx.CxxCore.CppNNS{Tuple{:std,:string}} (got String for argument 1)
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] check_args at /home/oberhuber/.julia/packages/Cxx/1RaOv/src/codegen.jl:447 [inlined]
 [3] _cppcall(::Type, ::Type, ::Bool, ::Bool, ::Tuple{DataType}) at /home/oberhuber/.julia/packages/Cxx/1RaOv/src/codegen.jl:516
 [4] #s37#41(::Any, ::Any, ::Any, ::Any) at /home/oberhuber/.julia/packages/Cxx/1RaOv/src/codegen.jl:849
 [5] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any,N} where N) at ./boot.jl:524
 [6] testCxx() at /mnt/ssd/tmp/jtnl/cxx-std-string-test.jl:11
 [7] top-level scope at /mnt/ssd/tmp/jtnl/cxx-std-string-test.jl:14
 [8] include at ./boot.jl:328 [inlined]
 [9] include_relative(::Module, ::String) at ./loading.jl:1105
 [10] include(::Module, ::String) at ./Base.jl:31
 [11] exec_options(::Base.JLOptions) at ./client.jl:287
 [12] _start() at ./client.jl:460
in expression starting at /mnt/ssd/tmp/jtnl/cxx-std-string-test.jl:14

If I replace the line

std_str = @cxxnew std::string( "123" )

with

std_str = @cxxnew std::string( )

it works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant