-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsizes.cpp
50 lines (41 loc) · 1.05 KB
/
sizes.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "faasm/faasm.h"
#include <iostream>
#include <typeinfo>
template<typename T>
void checkSizeOf(size_t expected, const char* name)
{
size_t actual = sizeof(T);
if (actual != expected) {
printf("Size of %s not as expected (expected %lu was %lu)\n",
name,
expected,
actual);
exit(1);
}
}
int main(int argc, char* argv[])
{
checkSizeOf<double>(8, "double");
checkSizeOf<float>(4, "float");
checkSizeOf<int>(4, "int");
#ifdef __wasm__
checkSizeOf<long>(4, "long");
checkSizeOf<long long>(8, "long long");
#else
checkSizeOf<long>(8, "long");
checkSizeOf<long long>(8, "long long");
#endif
checkSizeOf<short>(2, "short");
checkSizeOf<char>(1, "char");
checkSizeOf<off_t>(8, "off_t");
#ifdef __wasm__
int ptrSize = 4;
#else
int ptrSize = 8;
#endif
checkSizeOf<uintptr_t>(ptrSize, "uintptr_t");
checkSizeOf<intptr_t>(ptrSize, "intptr_t");
checkSizeOf<void*>(ptrSize, "void *");
checkSizeOf<size_t>(ptrSize, "size_t");
return 0;
}