History

core ejected

Ge Wang committed 9 years ago

Commit d38351c1 parent 74cf4d4158 files · +0 −196800Browse files

Showing the changes to src/scripts/platform.cpp (1 of 158 files). Show all

Unified · Split

src/scripts/platform.cpp+32−0
@@ -0,0 +1,32 @@
1// name: platform.cpp
2// desc: finds sizes
3// author: Ge Wang (gewang@cs.princeton.edu)
4
5#include <iostream>
6using namespace std;
7
8// union
9union X
10{
11 short s;
12 char b[2];
13};
14
15// entry point
16int main( int argc, char ** argv )
17{
18 X x;
19 x.s = 0x0100;
20
21 // go
22 cout << "char: " << sizeof(char) << endl;
23 cout << "short: " << sizeof(short) << endl;
24 cout << "int: " << sizeof(int) << endl;
25 cout << "long: " << sizeof(long) << endl;
26 cout << "float: " << sizeof(float) << endl;
27 cout << "double: " << sizeof(double) << endl;
28 cout << "void *: " << sizeof(void *) << endl;
29 cout << "endian: " << ( x.b[1] ? "small" : "big" ) << endl;
30
31 return 0;
32}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t