From 72a403ce29627ad6fb603c366b239ba8c9e5131e Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Wed, 30 Mar 2022 16:22:09 -0700 Subject: Allow C++ user code --- usr/cxx.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 usr/cxx.cpp (limited to 'usr/cxx.cpp') diff --git a/usr/cxx.cpp b/usr/cxx.cpp new file mode 100644 index 0000000..0c41cca --- /dev/null +++ b/usr/cxx.cpp @@ -0,0 +1,24 @@ +extern "C" { +#include +}; + +class TestClass { + public: + unsigned long value; + TestClass(unsigned long v) { + value = v; + } + void increment() { + value++; + } + void increment(unsigned long v) { + value += v; + } +}; + +extern "C" void cpp_demo(unsigned long v) +{ + TestClass tc = TestClass(v); + tc.increment(); + uart_hexn(tc.value); +} -- cgit v1.2.1