/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . Description Test the sizeof for basic types. Can be compiled and run without any OpenFOAM libraries. \*---------------------------------------------------------------------------*/ #include #include #include #include #include // Can also compile without OpenFOAM #ifdef WM_LABEL_SIZE #include "IOstreams.H" #endif template void print(const char* msg) { std::cout<< msg << ' ' << sizeof(T) << '\n'; } #ifdef WM_LABEL_SIZE template void printMax(const char* msg) { std::cout<< msg << ' ' << sizeof(T) << " max " << std::numeric_limits::max() << '\n'; Foam::Info<< msg << ' ' << sizeof(T) << " max " << long(std::numeric_limits::max()) << '\n'; } #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: int main(int argc, char *argv[]) { std::cout<<"machine sizes\n---\n\n"; print("mode_t"); print("short"); print("int"); print("long"); print("long long"); print("ushort"); print("uint"); print("ulong"); print("ulong-long"); print("int16"); print("int32"); print("int64"); print("uint16"); print("uint32"); print("uint64"); print("float"); print("double"); print("std::string"); print("std::string::size_type"); #ifdef WM_LABEL_SIZE std::cout<<"\nmax values\n---\n\n"; printMax("mode_t"); Foam::Info<< "mode_t 0777: " << mode_t(0777) << '\n'; printMax("short"); printMax("int"); printMax("long"); printMax("ushort"); printMax("uint"); printMax("ulong"); printMax("float"); printMax("double"); #endif std::cout << "\n---\nEnd\n\n"; return 0; } // ************************************************************************* //