Skip to content

enum with underlying type: char #73

@romainfrancois

Description

@romainfrancois
cpp11::cpp_source(code = '
#include <cpp11.hpp>

enum class Color : char { red, green = 20, blue };

[[cpp11::register]]
void fun(SEXP value) {
  cpp11::as_cpp<Color>(value);
}

', quiet = FALSE)
#> clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/Users/romainfrancois/.R/library/4.0/cpp11/include  -I/usr/local/include   -fPIC  -Wall -O3 -Wall -Wimplicit-int-float-conversion -c /private/var/folders/4b/hn4fq98s6810s4ccv2f9hm2h0000gn/T/RtmpzSpGdd/filef6b4538517d5/src/code_0.cpp -o /private/var/folders/4b/hn4fq98s6810s4ccv2f9hm2h0000gn/T/RtmpzSpGdd/filef6b4538517d5/src/code_0.o
#> In file included from /private/var/folders/4b/hn4fq98s6810s4ccv2f9hm2h0000gn/T/RtmpzSpGdd/filef6b4538517d5/src/code_0.cpp:2:
#> In file included from /Users/romainfrancois/.R/library/4.0/cpp11/include/cpp11.hpp:5:
#> /Users/romainfrancois/.R/library/4.0/cpp11/include/cpp11/as.hpp:80:27: error: call to function 'as_cpp' that is neither visible in the template definition nor found by argument-dependent lookup
#>     return static_cast<E>(as_cpp<typename std::underlying_type<E>::type>(from));
#>                           ^
#> /private/var/folders/4b/hn4fq98s6810s4ccv2f9hm2h0000gn/T/RtmpzSpGdd/filef6b4538517d5/src/code_0.cpp:8:10: note: in instantiation of function template specialization 'cpp11::as_cpp<Color>' requested here
#>   cpp11::as_cpp<Color>(value);
#>          ^
#> /Users/romainfrancois/.R/library/4.0/cpp11/include/cpp11/as.hpp:143:12: note: 'as_cpp' should be declared prior to the call site or in the global namespace
#> is_char<T> as_cpp(SEXP from) {
#>            ^
#> 1 error generated.
#> make: *** [/private/var/folders/4b/hn4fq98s6810s4ccv2f9hm2h0000gn/T/RtmpzSpGdd/filef6b4538517d5/src/code_0.o] Error 1
#> Error in dyn.load(shared_lib, local = TRUE, now = TRUE): unable to load shared object '/var/folders/4b/hn4fq98s6810s4ccv2f9hm2h0000gn/T//RtmpzSpGdd/filef6b4538517d5/src/code_0.so':
#>   dlopen(/var/folders/4b/hn4fq98s6810s4ccv2f9hm2h0000gn/T//RtmpzSpGdd/filef6b4538517d5/src/code_0.so, 6): image not found
fun(0L)
#> Error in .Call("_code_0_fun", value, PACKAGE = "code_0"): "_code_0_fun" not available for .Call() for package "code_0"

Created on 2020-08-05 by the reprex package (v0.3.0.9001)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions