Created
April 18, 2025 18:18
-
-
Save ragnarlodbrok1992/70470233e0f4ab301597da72c400b603 to your computer and use it in GitHub Desktop.
Bash function to create linux c++ boilerplate to quickly run code.
This file contains hidden or 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
cpp-placeholder() { | |
echo "Creating cpp boilerplate..." | |
echo "To run just do 'make'." | |
printf "# Compiler\nCXX = g++\n\n# Compiler flags\nCXXFLAGS = -Wall -Wextra -std=c++17\n\n# Output executable\nTARGET = main\n\n# Source file\nSRC = main.cpp\n\n# Default target\ndefault: all run clean\n\n# Build target\nall: \$(TARGET)\n\n# Compile the source file directly into executable\n\$(TARGET): \$(SRC)\n\t\$(CXX) \$(CXXFLAGS) -o \$(TARGET) \$(SRC)\n\n# Run the application\nrun: \$(TARGET)\n\t./\$(TARGET)\n\n# Clean the build files\nclean:\n\trm -f \$(TARGET)\n" > Makefile | |
printf "#include <stdio.h>\nint main(int argc, char** argv) {\n (void) argc;\n (void) argv;\n printf(\"Boilerplate file...\x5c\x6e\");\n return 0;\n}\n" > main.cpp | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment