Mac OS X Version 10.5.5 (Leopard) Apple MacBook 2.4 GHz Intel Core 2 Duo Script started on Mon Nov 10 11:44:44 2008 modric:~/2008F/ctec1335/lectures/week12$ cat sizes.cpp #include #include #include #include using namespace std ; #define printsizeof(t) \ cout << "size of " << #t << " is " << sizeof(t) << " bytes" << endl int main( ) { cout << "Data types:" << endl ; printsizeof(bool) ; printsizeof(char) ; printsizeof(short) ; printsizeof(int); printsizeof(long); printsizeof(float); printsizeof(double); printsizeof(string); printsizeof(ifstream); printsizeof(ofstream); printsizeof(vector); printsizeof(vector); printsizeof(vector); printsizeof(vector); cout << endl << "Pointer types:" << endl ; printsizeof(void*); printsizeof(bool*); printsizeof(char*); printsizeof(short*); printsizeof(int*); printsizeof(long*); printsizeof(float*); printsizeof(double*); printsizeof(string*); printsizeof(ifstream*); printsizeof(ofstream*); printsizeof(vector*); printsizeof(vector*); printsizeof(vector*); printsizeof(vector*); cout << endl << "Reference types:" << endl ; printsizeof(bool&); printsizeof(char&); printsizeof(short&); printsizeof(int&); printsizeof(long&); printsizeof(float&); printsizeof(double&); printsizeof(string&); printsizeof(ifstream&); printsizeof(vector&); printsizeof(vector&); printsizeof(vector&); printsizeof(vector&); } modric:~/2008F/ctec1335/lectures/week12$ uname -a Darwin modric.local 9.5.0 Darwin Kernel Version 9.5.0: Wed Sep 3 11:29:43 PDT 2008; root:xnu-1228.7.58~1/RELEASE_I386 i386 modric:~/2008F/ctec1335/lectures/week12$ g++ -dumpmachine i686-apple-darwin9 modric:~/2008F/ctec1335/lectures/week12$ g++ -dumpversion 4.0.1 modric:~/2008F/ctec1335/lectures/week12$ g++ -o sz sizes.cpp modric:~/2008F/ctec1335/lectures/week12$ g++ -m64 -o sz64 sizes.cpp modric:~/2008F/ctec1335/lectures/week12$ file sz* sz: Mach-O executable i386 sz64: Mach-O 64-bit executable x86_64 modric:~/2008F/ctec1335/lectures/week12$ ./sz Data types: size of bool is 1 bytes size of char is 1 bytes size of short is 2 bytes size of int is 4 bytes size of long is 4 bytes size of float is 4 bytes size of double is 8 bytes size of string is 4 bytes size of ifstream is 664 bytes size of ofstream is 664 bytes size of vector is 12 bytes size of vector is 12 bytes size of vector is 12 bytes size of vector is 12 bytes Pointer types: size of void* is 4 bytes size of bool* is 4 bytes size of char* is 4 bytes size of short* is 4 bytes size of int* is 4 bytes size of long* is 4 bytes size of float* is 4 bytes size of double* is 4 bytes size of string* is 4 bytes size of ifstream* is 4 bytes size of ofstream* is 4 bytes size of vector* is 4 bytes size of vector* is 4 bytes size of vector* is 4 bytes size of vector* is 4 bytes Reference types: size of bool& is 1 bytes size of char& is 1 bytes size of short& is 2 bytes size of int& is 4 bytes size of long& is 4 bytes size of float& is 4 bytes size of double& is 8 bytes size of string& is 4 bytes size of ifstream& is 664 bytes size of vector& is 12 bytes size of vector& is 12 bytes size of vector& is 12 bytes size of vector& is 12 bytes modric:~/2008F/ctec1335/lectures/week12$ ./sz64 Data types: size of bool is 1 bytes size of char is 1 bytes size of short is 2 bytes size of int is 4 bytes size of long is 8 bytes size of float is 4 bytes size of double is 8 bytes size of string is 8 bytes size of ifstream is 904 bytes size of ofstream is 896 bytes size of vector is 24 bytes size of vector is 24 bytes size of vector is 24 bytes size of vector is 24 bytes Pointer types: size of void* is 8 bytes size of bool* is 8 bytes size of char* is 8 bytes size of short* is 8 bytes size of int* is 8 bytes size of long* is 8 bytes size of float* is 8 bytes size of double* is 8 bytes size of string* is 8 bytes size of ifstream* is 8 bytes size of ofstream* is 8 bytes size of vector* is 8 bytes size of vector* is 8 bytes size of vector* is 8 bytes size of vector* is 8 bytes Reference types: size of bool& is 1 bytes size of char& is 1 bytes size of short& is 2 bytes size of int& is 4 bytes size of long& is 8 bytes size of float& is 4 bytes size of double& is 8 bytes size of string& is 8 bytes size of ifstream& is 904 bytes size of vector& is 24 bytes size of vector& is 24 bytes size of vector& is 24 bytes size of vector& is 24 bytes modric:~/2008F/ctec1335/lectures/week12$ exit Script done on Mon Nov 10 11:45:53 2008