Orthodoxy is a tool for programmers who believe that C++ needs less, not more.
Within C++, there is a much smaller and cleaner language struggling to get out.
— Bjarne Stroustrup
This project is open to feature requests. Feedback is appreciated.
Orthodoxy is a plugin for the Clang compiler, which selectively disables specific features of the C++ language. This way, a programmer can configure their own custom subset of the C++ language which is tailored to a particular project.
Create a configuration file in the project directory, and compile the
code with orthodox-clang++.
Under CMake, orthodoxy is easy to use. The following code will
enable it for all subsequent targets.
CMakeLists.txt
find_package(orthodoxy CONFIG OPTIONAL_COMPONENTS plugin) if(orthodoxy_plugin_FOUND) link_libraries(orthodoxy::plugin) endif()
See Reference for available rules, and the test folder
for a set of minimal examples.
.orthodoxy.yml
--- Class: false NonPOD: false Constructor: false Destructor: false Inheritance: false Access: false ImplicitThis: false NamedCast: false OperatorOverload: false ConversionOverload: false Reference: false Exception: false RangeBasedLoop: false Lambda: false New: false Auto: false DefaultArgument: false
If present in source code, any use of a disabled language features will raise a compilation error. One can suppress such errors on an individual basis by writing a comment on the same line as the element which raises the error.
example.cpp
static_cast<int>(x); /* HERESY(static-cast) */
Orthodoxy is able to forbid the use of certain system headers, using
the combination of a blacklist and a whitelist, defined respectively
by IncludeForbid and IncludeAllow.
The whitelist has priority over the blacklist.
.orthodoxy.yml
--- IncludeForbid: ["*"] IncludeAllow: ["*.h*", "atomic"]
For example, the rules above can be used to block the entire STL, with
the exception of one particular header (in this case <atomic>).
This compiler plugin tightly integrates with a particular version of the Clang compiler, so you have to compile a version that matches your installed compiler.
cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build
sudo cmake --build build --target installTODO: Help needed to write Windows-specific instructions and helper scripts.
-
InheritParent (bool)inherit from parent directory rules (default:false) -
IncludeForbid (list[string])patterns of forbidden system headers -
IncludeAllow (list[string])patterns of allowed system headers -
Class (bool)structures declared with theclasskeyword -
NonPOD (bool)non-POD structures-
NonTrivial (bool)non-trivial structures -
NonStandardLayout (bool)non-standard-layout structures
-
-
Constructor (bool)constructors-
CopyConstructor (bool)copy constructors -
MoveConstructor (bool)move constructors -
ConversionConstructor (bool)implicit constructors other than move and copy
-
-
Destructor (bool)destructors -
Inheritance (bool)inheritance, both virtual and non-virtual-
VirtualInheritance (bool)virtual inheritance
-
-
MemberFunction (bool)member functions-
VirtualMemberFunction (bool)virtual member functions
-
-
EnumClass (bool)enum classes -
Access (bool)member or inheritance access specifier-
MemberAccess (bool)member access specifier -
InheritanceAccess (bool)inheritance access specifier
-
-
ImplicitThis (bool)member access without an explicitthis -
CStyleCast (bool)C-style casts -
NamedCast (bool)all C++-style named casts-
DynamicCast (bool)dynamic casts -
StaticCast (bool)static casts -
ConstCast (bool)const casts -
ReinterpretCast (bool)reinterpret casts
-
-
Overload (bool)overloading, both function and operator-
FunctionOverload (bool)function overloading -
OperatorOverload (bool)operator overloading-
AssignmentOperator (bool)assignment operator-
CopyAssignmentOperator (bool)copy assignment operator -
MoveAssignmentOperator (bool)move assignment operator
-
-
-
ConversionOverload (bool)conversion operator overloading
-
-
Reference (bool)references of all kinds-
RvalueReference (bool)r-value references -
LvalueReference (bool)l-value references -
ReferenceToNonConst (bool)references to non-const types
-
-
Exception (bool)all exception handling-
Throw (bool)exception throwing -
TryCatch (bool)exception catching
-
-
Template (bool)templates-
Concept (bool)concepts
-
-
Module (bool)modules-
ModuleImport (bool)importing modules -
ModuleExport (bool)exporting modules
-
-
RangeBasedLoop (bool)range-based loop -
Lambda (bool)lambda functions-
LambdaCapture (bool)capturing lambda functions
-
-
New (bool)operatorsnewanddelete -
Auto (bool)declarations with automatic type-
AutoReturn (bool)function declarations with automatic return type -
AutoVariable (bool)variable declarations with automatic type
-
-
UserDefinedLiteral (bool)user-defined literals -
DefaultArgument (bool)default arguments -
Namespace (bool)namespaces -
NamespaceDepth (uint)maximum namespace depth (default:0, meaning infinity) -
Mutable (bool)variables declared with themutablequalifier
C++ is often considered a very complicated language, while C is very simplistic, and there exists no language in between to fill the gap. As C++ adds features and grows its standard library, complication worsens and compilation speed degrades.
Many developers limit themselves to more of less strict, vaguely defined subsets of C++. One such subset is known as Orthodox C++.
Orthodoxy is named after Orthodox C++ and its goal is to easily remodel C++ into a simpler, better C language according to the needs of a specific project.
The specifics will not be presented in this document. Refer to Orthodox C++ for a more elaborate discussion on the topic.
This program 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.