libplatform is a platform check library
- GNU Make
- GNU/Linux commands: cat, mkdir, install, rm, echo
make
make install
The build results are in the 'build' directory.
- cmd.exe on Windows
call make.cmd
make.cmd does not support install. The build results are in the 'build' directory.
- CMake (version >= 3.0)
mkdir build
cd build
cmake ..
The build results are in the 'build' directory.
- Python 3.x or Python 2.x
- Python base libraries (platform, shutil)
- Python build-in libraries (sys, os)
python tools/build.py
python tools/build.py install
Try 'python tools/build.py' --help for help
MS-DOS does not support long file names, so include output 'include\platform_predef.h' will be replaced to 'include\libplat.h'
- MS-DOS shell (COMMAND.COM)
cd tools
call dos-make.bat
dos-make.bat will chdir to repository root directory automatic. dos-make.bat does not support install. The build results are in the 'build' directory.
Do not use dos-make.bat for build on Windows!
After install, you can use libplatform in C/C++
#include <platform_predef.h>
/*On MS-DOS, <platform_predef.h> is renamed to <libplat.h>*/
#include <stdio.h>
int main()
{
if(__has_windows__)
{
printf("Compile in Windows!\n");
}
else
{
printf("Compile non-Windows!\n");
}
printf("Target arch:%s\n",__arch__);
printf("Target arch name:%s\n",__arch_name__);
printf("Pointer width:%d\n",__POINTER_WIDTH__);
}