Basics
Main File
A main file is the file that runcpp2 uses. It can either be a standalone build info yaml file or a source file (which contains build info yaml as inline comment, optionally).
To embedding build info as an inline comment, simply put runcpp2 in the first line, whether it is
a block comment or line comment (with or without space).
A single main file can only produce a single binary output, with the same name as the main file.
Suppose you have a c++ file called main.cpp, you can run it immediately by doing
Note
On Unix, if you have added runcpp2 to your PATH and add this line
//bin/true;runcpp2 run "$0" "$@"; exit $?;
to the top of your script, you can run the script directly by ./main.cpp <arguments>
For full reference on all the available build info options, see Build Info Reference
A build info template can also be generated with the following command
runcpp2 template ./main.cpp # Embeds the build settings template as comment
runcpp2 template ./main.yaml # Creates the build settings template as dedicated yaml file
Error Feedback
If you want a live error feedback, you can use "watch" mode.
Platforms And Profiles
A platform represents a single host operating systems (not the target platform).
A profile represents a single configuration of compiler/linker toolchain.
List Of Platforms
runcpp2 supports the following platforms:
- Windows
- Linux
- MacOS
- Unix (Linux and MacOS)
Todo
Custom platforms
Default Profiles
Below are the built-in profiles:
- g++: GNU c++ compiler (with alias "mingw")
- vs2022_v17+: Visual Studio 2022 compiler (with aliases "msvc1930+", "msvc")
- clang++
- clang
Custom profiles can be added by editing the user config file. For full reference, see User Config Reference
You can find all the profiles in the directory returned by runcpp2 show-config-path
Specifying Build Info Values
You can specify a value that applies to all platforms and profiles like so
However, you can also specify a value per platform/profile with the following syntax
For example
Defines:
Windows:
"g++": ["OS=Windows", "Compiler=g++"]
"msvc": ["OS=Windows", "Compiler=msvc"]
Linux:
"g++": ["OS=Linux", "Compiler=g++"]
You can also specify values that apply to all platforms or profiles with the following keywords
- DefaultPlatform: Settings that apply to any platform that doesn't have explicit settings
- DefaultProfile: Settings that apply to any profile that doesn't have explicit settings
For example
Defines:
DefaultPlatform:
"g++": ["Compiler=g++"]
"msvc": ["Compiler=msvc"]
DefaultProfile: ["Compiler=other"]
in this case Compiler is defined to the name of the profile regardless of which platform you are on,
unless you are using a profile that is not g++ or msvc in which case it will be defined as other
instead.