summaryrefslogtreecommitdiff
path: root/userspace/cpp/testcpp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'userspace/cpp/testcpp.cpp')
-rw-r--r--userspace/cpp/testcpp.cpp48
1 files changed, 34 insertions, 14 deletions
diff --git a/userspace/cpp/testcpp.cpp b/userspace/cpp/testcpp.cpp
index 53e3a3b..8ed7d55 100644
--- a/userspace/cpp/testcpp.cpp
+++ b/userspace/cpp/testcpp.cpp
@@ -3,31 +3,51 @@
#include <cstdio>
#include <iostream>
-void prep();
-void myinit();
+struct test
+{
+ int i;
+ test(int ii):i(ii) { printf("test:ctor %i\n",i); }
+ ~test() { printf("test:dtor %i\n",i ); }
+};
+
+test t1(1); // global constructor should get called and desctructed on exit from our crt0
+
+int somefunc()
+{
+ test t2(2);
+}
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
+ printf(" --- testing ctors & dtors ---\n");
- // using default comparison (operator <):
- std::sort (myvector.begin(), myvector.begin()+4); //(12 32 45 71)26 80 53 33
+ somefunc();
+ test t3(3);
- 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;
+
+ /*
+
+ 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
+ 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("hello\n");
+ */
+ printf("-- fin -- \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);
// constructing vectors
/*
#include <iostream>