-
-
Save anonymous/bd0db5e4bcb307b70506 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Built with: clang++ -O3 -g -std=gnu++11 -stdlib=libc++ foo.cpp -o foo | |
#include <fstream> | |
#include <iostream> | |
#define PRINT_INFO(x) std::cout << "sizeof(" #x ")=" << sizeof(x) << ", offset=" << ((char*)(x*)&zero - (char*)&zero) << '\n' | |
int main() | |
{ | |
std::ifstream zero("/dev/zero"); | |
PRINT_INFO(std::ifstream); | |
PRINT_INFO(std::istream); | |
PRINT_INFO(std::ios); | |
PRINT_INFO(std::ios_base); | |
return zero.get(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Built with Xcode 4.6's clang: | |
themac:~ jorgen$ ./foo | |
sizeof(std::ifstream)=448, offset=0 | |
sizeof(std::istream)=168, offset=0 | |
sizeof(std::ios)=152, offset=296 | |
sizeof(std::ios_base)=136, offset=296 | |
# Built with Xcode 5.1's clang: | |
themac:~ jorgen$ ./foo-modern | |
sizeof(std::ifstream)=576, offset=0 | |
sizeof(std::istream)=168, offset=0 | |
sizeof(std::ios)=152, offset=424 | |
sizeof(std::ios_base)=136, offset=424 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment