summaryrefslogtreecommitdiffstatshomepage
path: root/examples/usercmodule/cppexample
diff options
context:
space:
mode:
authorstijn <stijn@ignitron.net>2023-11-13 16:04:40 +0100
committerDamien George <damien@micropython.org>2023-11-17 14:31:42 +1100
commita968888f69d94890e8851efe38ace3b9448552d7 (patch)
tree7ac93b59f763373e589bd27be4e235b46d29e4ef /examples/usercmodule/cppexample
parent92741a34388e85d07e26511ff81b27af99445f00 (diff)
downloadmicropython-a968888f69d94890e8851efe38ace3b9448552d7.tar.gz
micropython-a968888f69d94890e8851efe38ace3b9448552d7.zip
py/obj: Fix mp_obj_is_type compilation with C++.
Fixes issue #12951. Signed-off-by: stijn <stijn@ignitron.net>
Diffstat (limited to 'examples/usercmodule/cppexample')
-rw-r--r--examples/usercmodule/cppexample/example.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/examples/usercmodule/cppexample/example.cpp b/examples/usercmodule/cppexample/example.cpp
index 06809732a4..2df832baa7 100644
--- a/examples/usercmodule/cppexample/example.cpp
+++ b/examples/usercmodule/cppexample/example.cpp
@@ -1,9 +1,16 @@
extern "C" {
#include <examplemodule.h>
+#include <py/objstr.h>
// Here we implement the function using C++ code, but since it's
// declaration has to be compatible with C everything goes in extern "C" scope.
mp_obj_t cppfunc(mp_obj_t a_obj, mp_obj_t b_obj) {
+ // The following no-ops are just here to verify the static assertions used in
+ // the public API all compile with C++.
+ MP_STATIC_ASSERT_STR_ARRAY_COMPATIBLE;
+ if (mp_obj_is_type(a_obj, &mp_type_BaseException)) {
+ }
+
// Prove we have (at least) C++11 features.
const auto a = mp_obj_get_int(a_obj);
const auto b = mp_obj_get_int(b_obj);