Skip to content

avoid using EXTPTR_PTR #1097

@kevinushey

Description

@kevinushey

As it's not part of the official R API. See https://r.789695.n4.nabble.com/Possible-ABI-change-in-R-4-0-1-td4764335.html for details.

We should use R_ExternalPtrAddtr() instead.

kevinushey@cdrv:~/r/pkg/Rcpp [master]
$ rg "EXTPTR_PTR"
inst/include/Rcpp/module/class.h
170:                vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( EXTPTR_PTR( method_xp ) ) ;
197:                vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( EXTPTR_PTR( method_xp ) ) ;
219:                vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( EXTPTR_PTR( method_xp ) ) ;
396:                prop_class* prop = reinterpret_cast< prop_class* >( EXTPTR_PTR( field_xp ) ) ;
403:                prop_class* prop = reinterpret_cast< prop_class* >( EXTPTR_PTR( field_xp ) ) ;

src/api.cpp
148:    snprintf(buffer, 20, "%p", (void*)EXTPTR_PTR(xp));

src/module.cpp
56:    return EXTPTR_PTR(xp) == 0;

Evidently this change was done way back in 2011 as well for some usages:

Rcpp/ChangeLog

Lines 6630 to 6634 in b125470

2011-02-10 Douglas Bates <bates@stat.wisc.edu>
* inst/include/Rcpp/XPtr.h: Replace calls to EXTPTR_PTR with
R_ExternalPtrAddr. The distinction is important when R is
compiled with PROTECTCHECK enabled.

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