analytech-solutions / CBinding.jl

Automatic C interfacing for Julia
MIT License
132 stars 7 forks source link

ERROR: LoadError: MethodError: no method matching *(::Nothing, ::SubString{String}) #94

Closed KajWiik closed 2 years ago

KajWiik commented 2 years ago

I tried to make bindings to the liquid-dsp library:

cd /tmp
git clone https://github.com/jgaeddert/liquid-dsp.git
cd liquid-dsp/
./bootstrap.sh
./configure
make

And in Julia REPL:

using CBinding
c` -std=gnu99 -Wall -I/tmp/liquid-dsp/include -L/tmp/liquid-dsp -lliquid`
c"""
#include <liquid.h>
"""jw

This leads to a strange error:

ERROR: LoadError: MethodError: no method matching *(::Nothing, ::SubString{String})
Closest candidates are:
  *(::Any, ::Any, ::Any, ::Any...) at /opt/julia-1.7.1/share/julia/base/operators.jl:655
  *(::Union{AbstractChar, AbstractString}, ::Union{AbstractChar, AbstractString}...) at /opt/julia-1.7.1/share/julia/base/strings/basic.jl:260
  *(::Missing, ::Union{AbstractChar, AbstractString}) at /opt/julia-1.7.1/share/julia/base/missing.jl:182
  ...
Stacktrace:
 [1] getexprs_macro(ctx::CBinding.Context{:c}, cursor::CBinding.libclang.var"(c\"CXCursor\")")
   @ CBinding ~/.julia/packages/CBinding/kBUap/src/context_c.jl:748
 [2] getexprs(ctx::CBinding.Context{:c}, cursor::CBinding.libclang.var"(c\"CXCursor\")")
   @ CBinding ~/.julia/packages/CBinding/kBUap/src/context_c.jl:332
 [3] getexprs(ctx::CBinding.Context{:c})
   @ CBinding ~/.julia/packages/CBinding/kBUap/src/context.jl:127
 [4] clang_str(mod::Module, loc::LineNumberNode, lang::Symbol, str::String, opts::String)
   @ CBinding ~/.julia/packages/CBinding/kBUap/src/context.jl:482
 [5] var"@c_str"(__source__::LineNumberNode, __module__::Module, exprs::Vararg{Any})
   @ CBinding ~/.julia/packages/CBinding/kBUap/src/context_c.jl:5
in expression starting at REPL[4]:1

Any suggestions?

There are also a number of warnings like

┌ Warning: Failed to find `symtrack_rrrf_create` in:
│   /tmp/liquid-dsp/libliquid
│   or the Julia process
└ @ CBinding ~/.julia/packages/CBinding/kBUap/src/context.jl:48

but grepping the whole source does not find any reference to symtrack_rrrf_create. Probably harmless?

krrutkow commented 2 years ago

whole source does not find any reference to symtrack_rrrf_create.

There is a lot of cringe-worthy macro usage in the header... Those symbols do not appear to exist in the library, but the header is describing them as if they should exist in it. You can add q to your string macro options to not see those warnings since they are just informing you that those symbols will not be bound to anything in the library.

krrutkow commented 2 years ago

I forgot to mention, you can also add the m string macro option to avoid this bug if there is nothing in the C macros you need to use. There are a couple of other issues that need to be addressed before this is available in the next package release.