From 8b33f268b67455ded8d35f3c198425562173fa2e Mon Sep 17 00:00:00 2001 From: Miguel Date: Thu, 11 Oct 2018 02:14:52 +0200 Subject: almost cross compliing c++ --- userspace/cpp/Makefile | 11 ++++++++++- userspace/cpp/prep.cpp | 8 ++++++++ userspace/cpp/testcpp.cpp | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 userspace/cpp/prep.cpp (limited to 'userspace/cpp') diff --git a/userspace/cpp/Makefile b/userspace/cpp/Makefile index 7623325..9f4b314 100644 --- a/userspace/cpp/Makefile +++ b/userspace/cpp/Makefile @@ -1,6 +1,15 @@ CXX=i686-foolos-g++ -testcpp: +CFLAGS= +CFLAGS+=-O0 +CFLAGS+=-gstabs + +LDLIBS+=-lgcc + +ASFLAGS= +ASFLAGS+=-gstabs + +testcpp: prep.cpp clean: rm -f testcpp diff --git a/userspace/cpp/prep.cpp b/userspace/cpp/prep.cpp new file mode 100644 index 0000000..a09adbe --- /dev/null +++ b/userspace/cpp/prep.cpp @@ -0,0 +1,8 @@ +#include +#include + +void prep() +{ +_REENT_INIT_PTR(_impure_ptr); +} + diff --git a/userspace/cpp/testcpp.cpp b/userspace/cpp/testcpp.cpp index 0e89276..53e3a3b 100644 --- a/userspace/cpp/testcpp.cpp +++ b/userspace/cpp/testcpp.cpp @@ -1,4 +1,35 @@ +#include +#include +#include +#include + +void prep(); +void myinit(); + +int main() +{ + prep(); + myinit(); + + int myints[] = {32,71,12,45,26,80,53,33}; + std::vector myvector (myints, myints+8); // 32 71 12 45 26 80 53 33 + + // using default comparison (operator <): + std::sort (myvector.begin(), myvector.begin()+4); //(12 32 45 71)26 80 53 33 + + for (std::vector::iterator it=myvector.begin(); it!=myvector.end(); ++it) + printf("%i\n",*it); + printf("hello\n"); + +// printf("reent struct size: %d bytes\n",sizeof(struct _reent)); + // printf("reent pointer : 0x%08x\n",_impure_ptr); + //printf("reent pointer : 0x%08x\n",_impure_ptr); + std::cout << "bye bye" << std::endl; + printf("hello\n"); +} + // constructing vectors +/* #include #include #include @@ -8,6 +39,7 @@ int main() { + std::cout << "hi" << std::endl; _REENT_INIT_PTR(_impure_ptr); @@ -32,3 +64,4 @@ int main() return 0; } +*/ -- cgit v1.2.3