Rename the hello subdirectory to test

This commit is contained in:
Martin Storsjö committed 2018-03-20 11:08:32 +02:00
1 parent ee480fec72
commit d7d80f084a
7 files changed
+7 -7

No files matched your search

+1
View File
@@ -0,0 +1 @@
*.exe
+49
View File
@@ -0,0 +1,49 @@
#include <iostream>
#include <stdio.h>
class Hello {
public:
Hello() {
printf("Hello ctor\n");
}
~Hello() {
printf("Hello dtor\n");
}
};
Hello global_h;
class RecurseClass {
public:
RecurseClass(int v) : val(v) {
printf("ctor %d\n", val);
}
~RecurseClass() {
printf("dtor %d\n", val);
}
private:
int val;
};
void recurse(int val) {
RecurseClass obj(val);
if (val == 0) {
throw std::exception();
}
if (val == 5) {
try {
recurse(val - 1);
} catch (std::exception& e) {
printf("caught exception at %d\n", val);
}
} else {
recurse(val - 1);
}
printf("finishing function recurse %d\n", val);
}
int main(int argc, char* argv[]) {
std::cout<<"Hello world C++"<<std::endl;
recurse(10);
return 0;
}
+37
View File
@@ -0,0 +1,37 @@
#include <windows.h>
#include <stdio.h>
#include <process.h>
#if defined(_MSC_VER)
static __declspec(thread) int tlsvar = 1;
#else
static __thread int tlsvar = 1;
#endif
static unsigned __stdcall threadfunc(void* arg) {
int id = (int)arg;
printf("thread %d, tlsvar %p initially %d\n", id, &tlsvar, tlsvar);
tlsvar = id + 100;
for (int i = 0; i < 4; i++) {
printf("thread %d, tlsvar %p %d\n", id, &tlsvar, tlsvar);
tlsvar += 10;
Sleep(500);
}
return 0;
}
int main(int argc, char* argv[]) {
HANDLE threads[3];
for (int i = 0; i < 3; i++) {
printf("mainthread, tlsvar %p %d\n", &tlsvar, tlsvar);
tlsvar += 10;
threads[i] = (HANDLE)_beginthreadex(NULL, 0, threadfunc, (void*)(intptr_t) (i + 1), 0, NULL);
Sleep(350);
}
for (int i = 0; i < 3; i++) {
WaitForSingleObject(threads[i], INFINITE);
CloseHandle(threads[i]);
}
return 0;
}
+7
View File
@@ -0,0 +1,7 @@
#define __USE_MINGW_ANSI_STDIO 1
#include <stdio.h>
int main(int argc, char* argv[]) {
printf("hello world! %f\n", 42.0);
return 0;
}
+18
View File
@@ -0,0 +1,18 @@
#include <iostream>
class Hello {
public:
Hello() {
printf("Hello ctor\n");
}
~Hello() {
printf("Hello dtor\n");
}
};
Hello global_h;
int main(int argc, char* argv[]) {
std::cout<<"Hello world C++"<<std::endl;
return 0;
}