summaryrefslogtreecommitdiff
path: root/userspace/cpp
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-10-11 02:14:52 +0200
committerMiguel <m.i@gmx.at>2018-10-11 02:14:52 +0200
commit8b33f268b67455ded8d35f3c198425562173fa2e (patch)
tree947e9b5503c0447f12f6d8d2c00c3b177dddef72 /userspace/cpp
parente2005fda57ea4da12754d67ba127b09508125395 (diff)
almost cross compliing c++
Diffstat (limited to 'userspace/cpp')
-rw-r--r--userspace/cpp/Makefile11
-rw-r--r--userspace/cpp/prep.cpp8
-rw-r--r--userspace/cpp/testcpp.cpp33
3 files changed, 51 insertions, 1 deletions
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 <reent.h>
+#include <cstring>
+
+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 <algorithm>
+#include <vector>
+#include <cstdio>
+#include <iostream>
+
+void prep();
+void myinit();
+
+int main()
+{
+ prep();
+ myinit();
+
+ int myints[] = {32,71,12,45,26,80,53,33};
+ std::vector<int> 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<int>::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 <iostream>
#include <vector>
#include <cstring>
@@ -8,6 +39,7 @@
int main()
{
+ std::cout << "hi" << std::endl;
_REENT_INIT_PTR(_impure_ptr);
@@ -32,3 +64,4 @@ int main()
return 0;
}
+*/