You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a void-returning function marked with cpp11::register is indented, cpp11 fails to recognize the void return type and will try to use its result in the wrapper it generates.
# This workscpp11::cpp_source(code="[[cpp11::register]]\nvoid foo() {}")
# This fails to compile. Note the extra space character between the newline and voidcpp11::cpp_source(code="[[cpp11::register]]\n void foo() {}")
using C++ compiler: ‘g++ (GCC) 14.2.1 20241116’
using C++11
/tmp/nix-shell.Cz8fPO/RtmpadKzBh/code_16bff7617b36f0.cpp:2:11: warning: ‘cpp11::register’ scoped attribute directive ignored [-Wattributes]
2 | void foo() {}
| ^
/tmp/nix-shell.Cz8fPO/RtmpadKzBh/file16bff7121f1a99/src/cpp11.cpp: In function ‘SEXPREC* _code_16bff7617b36f0_foo()’:
/tmp/nix-shell.Cz8fPO/RtmpadKzBh/file16bff7121f1a99/src/cpp11.cpp:7:30: error: invalid use of void expression
7 | return cpp11::as_sexp(foo());
| ~~~^~
make: *** [/nix/store/bb3gfb6b740ha50bbwvbgslybnqm0vgf-R-4.4.3/lib/R/etc/Makeconf:204: /tmp/nix-shell.Cz8fPO/RtmpadKzBh/file16bff7121f1a99/src/cpp11.o] Error 1
Error: Compilation failed.
The same behaviour happens when using an external file instead of an inline code = argument.
packageVersion("cpp11")
#> [1] ‘0.5.2’
The text was updated successfully, but these errors were encountered:
hi @plietar
I use cpp11 in my lab
I proposed a fix to decor such that signature becomes "void foo()" (not " void foo()"), and the C parser shall see the void return type and generate the correct (void‐returning) wrapper r-lib/decor@main...pachadotdev:decor:patch-1
If a void-returning function marked with
cpp11::register
is indented, cpp11 fails to recognize the void return type and will try to use its result in the wrapper it generates.The same behaviour happens when using an external file instead of an inline
code =
argument.The text was updated successfully, but these errors were encountered: