diff options
author | Sven Gothel <[email protected]> | 2022-10-11 12:35:27 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2022-10-11 12:35:27 +0200 |
commit | c0440adc79e14fa4e442c0612bc4f85eee73769f (patch) | |
tree | 4710cdf65008c3ad7b12661242aee99e8af917e1 |
Initial commit
-rw-r--r-- | .cproject | 126 | ||||
-rw-r--r-- | .externalToolBuilders/org.eclipse.cdt.core.cBuilder.launch | 7 | ||||
-rw-r--r-- | .project | 37 | ||||
-rw-r--r-- | .settings/language.settings.xml | 25 | ||||
-rw-r--r-- | .settings/org.eclipse.cdt.managedbuilder.core.prefs | 13 | ||||
-rw-r--r-- | Makefile | 25 | ||||
-rw-r--r-- | README.md | 31 | ||||
-rw-r--r-- | src/lesson00.cpp | 63 | ||||
-rw-r--r-- | src/lesson00_module.cpp | 13 |
9 files changed, 340 insertions, 0 deletions
diff --git a/.cproject b/.cproject new file mode 100644 index 0000000..f19a1f4 --- /dev/null +++ b/.cproject @@ -0,0 +1,126 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> + <storageModule moduleId="org.eclipse.cdt.core.settings"> + <cconfiguration id="cdt.managedbuild.config.gnu.exe.debug.1722717719"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.1722717719" moduleId="org.eclipse.cdt.core.settings" name="Debug"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.1722717719" name="Debug" parent="cdt.managedbuild.config.gnu.exe.debug"> + <folderInfo id="cdt.managedbuild.config.gnu.exe.debug.1722717719." name="/" resourcePath=""> + <toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.1502729378" name="Linux GCC" nonInternalBuilderId="cdt.managedbuild.target.gnu.builder.exe.debug" superClass="cdt.managedbuild.toolchain.gnu.exe.debug"> + <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.2071864214" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/> + <builder autoBuildTarget="all" buildPath="${workspace_loc:/cpp_basics}/Debug" cleanBuildTarget="clean" id="org.eclipse.cdt.build.core.internal.builder.1470606419" incrementalBuildTarget="all" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="org.eclipse.cdt.build.core.internal.builder"/> + <tool id="cdt.managedbuild.tool.gnu.archiver.base.646341821" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.778351646" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug"> + <option id="gnu.cpp.compiler.exe.debug.option.optimization.level.125514454" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/> + <option defaultValue="gnu.cpp.compiler.debugging.level.max" id="gnu.cpp.compiler.exe.debug.option.debugging.level.893852921" name="Debug Level" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" useByScannerDiscovery="false" valueType="enumerated"/> + <option id="gnu.cpp.compiler.option.dialect.std.2052620273" superClass="gnu.cpp.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.cpp.compiler.dialect.c++17" valueType="enumerated"/> + <option id="gnu.cpp.compiler.option.warnings.extrawarn.545779511" superClass="gnu.cpp.compiler.option.warnings.extrawarn" useByScannerDiscovery="false" value="true" valueType="boolean"/> + <option id="gnu.cpp.compiler.option.warnings.toerrors.128916151" superClass="gnu.cpp.compiler.option.warnings.toerrors" useByScannerDiscovery="false" value="true" valueType="boolean"/> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1624640898" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.2087160072" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug"> + <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.exe.debug.option.optimization.level.1866026409" name="Optimization Level" superClass="gnu.c.compiler.exe.debug.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/> + <option defaultValue="gnu.c.debugging.level.max" id="gnu.c.compiler.exe.debug.option.debugging.level.415407347" name="Debug Level" superClass="gnu.c.compiler.exe.debug.option.debugging.level" useByScannerDiscovery="false" valueType="enumerated"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.753609266" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.2046972051" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.315857968" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug"> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.887126468" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input"> + <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> + <additionalInput kind="additionalinput" paths="$(LIBS)"/> + </inputType> + </tool> + <tool id="cdt.managedbuild.tool.gnu.assembler.exe.debug.611471329" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.644291621" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + </toolChain> + </folderInfo> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> + </cconfiguration> + <cconfiguration id="cdt.managedbuild.config.gnu.exe.release.15962763"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.15962763" moduleId="org.eclipse.cdt.core.settings" name="Release"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.15962763" name="Release" parent="cdt.managedbuild.config.gnu.exe.release"> + <folderInfo id="cdt.managedbuild.config.gnu.exe.release.15962763." name="/" resourcePath=""> + <toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.210936688" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release"> + <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.1988156053" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/> + <builder buildPath="${workspace_loc:/cpp_basics}/Release" id="cdt.managedbuild.target.gnu.builder.exe.release.1971978546" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.release"/> + <tool id="cdt.managedbuild.tool.gnu.archiver.base.644817440" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.296322286" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release"> + <option id="gnu.cpp.compiler.exe.release.option.optimization.level.529114192" name="Optimization Level" superClass="gnu.cpp.compiler.exe.release.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/> + <option defaultValue="gnu.cpp.compiler.debugging.level.none" id="gnu.cpp.compiler.exe.release.option.debugging.level.1560305576" name="Debug Level" superClass="gnu.cpp.compiler.exe.release.option.debugging.level" useByScannerDiscovery="false" valueType="enumerated"/> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.786443527" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.1962541001" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release"> + <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.exe.release.option.optimization.level.2017777102" name="Optimization Level" superClass="gnu.c.compiler.exe.release.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/> + <option defaultValue="gnu.c.debugging.level.none" id="gnu.c.compiler.exe.release.option.debugging.level.17854753" name="Debug Level" superClass="gnu.c.compiler.exe.release.option.debugging.level" useByScannerDiscovery="false" valueType="enumerated"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1944066993" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.linker.exe.release.2142420230" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.102714458" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release"> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1940100752" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input"> + <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> + <additionalInput kind="additionalinput" paths="$(LIBS)"/> + </inputType> + </tool> + <tool id="cdt.managedbuild.tool.gnu.assembler.exe.release.425225889" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1118546175" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + </toolChain> + </folderInfo> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> + </cconfiguration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.pathentry"> + <pathentry kind="out" path="build"/> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <project id="cpp_basics.cdt.managedbuild.target.gnu.exe.1891976898" name="Executable" projectType="cdt.managedbuild.target.gnu.exe"/> + </storageModule> + <storageModule moduleId="scannerConfiguration"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1722717719;cdt.managedbuild.config.gnu.exe.debug.1722717719.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.2087160072;cdt.managedbuild.tool.gnu.c.compiler.input.753609266"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.15962763;cdt.managedbuild.config.gnu.exe.release.15962763.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.296322286;cdt.managedbuild.tool.gnu.cpp.compiler.input.786443527"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.15962763;cdt.managedbuild.config.gnu.exe.release.15962763.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.1962541001;cdt.managedbuild.tool.gnu.c.compiler.input.1944066993"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1722717719;cdt.managedbuild.config.gnu.exe.debug.1722717719.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.778351646;cdt.managedbuild.tool.gnu.cpp.compiler.input.1624640898"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> + <storageModule moduleId="refreshScope" versionNumber="2"> + <configuration configurationName="Debug"> + <resource resourceType="PROJECT" workspacePath="/cpp_basics"/> + </configuration> + <configuration configurationName="Release"> + <resource resourceType="PROJECT" workspacePath="/cpp_basics"/> + </configuration> + </storageModule> +</cproject>
\ No newline at end of file diff --git a/.externalToolBuilders/org.eclipse.cdt.core.cBuilder.launch b/.externalToolBuilders/org.eclipse.cdt.core.cBuilder.launch new file mode 100644 index 0000000..d8b1ede --- /dev/null +++ b/.externalToolBuilders/org.eclipse.cdt.core.cBuilder.launch @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType"> + <booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/> + <stringAttribute key="org.eclipse.ui.externaltools.ATTR_DISABLED_BUILDER" value="org.eclipse.cdt.core.cBuilder"/> + <mapAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"/> + <booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/> +</launchConfiguration> diff --git a/.project b/.project new file mode 100644 index 0000000..7df905f --- /dev/null +++ b/.project @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>cpp_basics</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> + <triggers>clean,full,incremental,</triggers> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> + <triggers>full,incremental,</triggers> + <arguments> + <dictionary> + <key>LaunchConfigHandle</key> + <value><project>/.externalToolBuilders/org.eclipse.cdt.core.cBuilder.launch</value> + </dictionary> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> + <triggers>full,incremental,</triggers> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.core.ccnature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> + </natures> +</projectDescription> diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml new file mode 100644 index 0000000..ac1207d --- /dev/null +++ b/.settings/language.settings.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<project> + <configuration id="cdt.managedbuild.config.gnu.exe.debug.1722717719" name="Debug"> + <extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> + <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> + <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/> + <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> + <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-394275885746499221" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true"> + <language-scope id="org.eclipse.cdt.core.gcc"/> + <language-scope id="org.eclipse.cdt.core.g++"/> + </provider> + </extension> + </configuration> + <configuration id="cdt.managedbuild.config.gnu.exe.release.15962763" name="Release"> + <extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> + <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> + <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/> + <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> + <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-394279319252045303" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true"> + <language-scope id="org.eclipse.cdt.core.gcc"/> + <language-scope id="org.eclipse.cdt.core.g++"/> + </provider> + </extension> + </configuration> +</project>
\ No newline at end of file diff --git a/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/.settings/org.eclipse.cdt.managedbuilder.core.prefs new file mode 100644 index 0000000..4165221 --- /dev/null +++ b/.settings/org.eclipse.cdt.managedbuilder.core.prefs @@ -0,0 +1,13 @@ +eclipse.preferences.version=1 +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1722717719/CPATH/delimiter=\: +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1722717719/CPATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1722717719/CPLUS_INCLUDE_PATH/delimiter=\: +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1722717719/CPLUS_INCLUDE_PATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1722717719/C_INCLUDE_PATH/delimiter=\: +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1722717719/C_INCLUDE_PATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1722717719/append=true +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1722717719/appendContributed=true +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.1722717719/LIBRARY_PATH/delimiter=\: +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.1722717719/LIBRARY_PATH/operation=remove +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.1722717719/append=true +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.1722717719/appendContributed=true diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..463a8a8 --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +# A simple Makefile for compiling small SDL projects + +# set the compiler +CPP := g++ -x c++ -std=c++17 -c +LN := g++ + +# set the compiler flags +CPPFLAGS := -ggdb3 -O0 -Wall +LNFLAGS := -ggdb3 -O0 -Wall -lm + +obj/%.o: src/%.cpp $(HEADERS) Makefile + mkdir -p obj + $(CPP) -o $@ $(CPPFLAGS) $< + +bin/lesson00: obj/lesson00.o obj/lesson00_module.o + mkdir -p bin + $(LN) -o $@ $^ $(LNFLAGS) + +# default recipe +all: bin/lessons00 + +clean: + rm -rf obj bin Debug build + +.PHONY: all clean diff --git a/README.md b/README.md new file mode 100644 index 0000000..486756c --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# C++ Basics, simple C++ lessons for our computer science class + +[Original document location](https://jausoft.com/cgit/cs_class/cpp_basics.git/about/). + +## Git Repository +This project's canonical repositories is hosted on [Gothel Software](https://jausoft.com/cgit/cs_class/cpp_basics.git/). + +## Goals +This project aims to demonstrate the C++ language +for our computer science class. + +## Supported Platforms +C++17 and better. + +## Building Binaries +The project requires make and g++ >= 8.3 for building. + +Installing build dependencies on Debian (11 or better): +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.sh} +apt install git build-essential g++ gcc libc-dev make +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +For a generic build use: +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.sh} +git clone https://jausoft.com/cgit/cs_class/arithmetic.git +cd cpp_basics +make +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The binaries shall reside within `bin`. + diff --git a/src/lesson00.cpp b/src/lesson00.cpp new file mode 100644 index 0000000..f31542d --- /dev/null +++ b/src/lesson00.cpp @@ -0,0 +1,63 @@ +//============================================================================ +// Name : arithmetic.cpp +// Author : Svenson Han Gothel and Sven Gothel +// Version : 0.1 +// Copyright : MIT +// Description : Applied artihmetic using C++ +//============================================================================ + +#include <cstdio> +#include <iostream> + +// function declaration +int add(const int x, const int y); + +// function definition +int add(const int x, const int y) { + return x + y; +} + +// function declaration +int double_value(const int x); + +int main(int argc, const char* argv[]) { + { + // entering scope-1, constructing `a` while initializing w/ `3` + int a=3; + { + // entering this scope-2, constructing `b` w/ `4` + int b=4; + int r = a + b; + (void)r; // avoid unused warnings + // leaving this scope-2, b will be destructed + } + // int r = a + b; // b is out of scope + } + { + // scope + for(int i=0; i<argc; i++) { + fprintf(stderr, "main.arg[%d]: %s\n", i, argv[i]); + } + } + + int error_counter = 0; + { + const int res = add(1, 2); + if( 3 != res ) { + ++error_counter; + } + } + { + const int res = double_value(1); + if( 2 != res ) { + ++error_counter; + } + } + if( 0 == error_counter ) { + std::cout << "No error" << std::endl; + return 0; + } else { + std::cout << error_counter << " error(s)" << std::endl; + return 1; + } +} diff --git a/src/lesson00_module.cpp b/src/lesson00_module.cpp new file mode 100644 index 0000000..8a9c867 --- /dev/null +++ b/src/lesson00_module.cpp @@ -0,0 +1,13 @@ +/* + * module.cpp + * + * Created on: Oct 11, 2022 + * Author: sven + */ + + +int double_value(const int x) { + return 2 * x; +} + + |