Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 0 additions & 80 deletions .github/workflow/build_and_test.yml

This file was deleted.

24 changes: 14 additions & 10 deletions .github/workflows/test_scripts/check_compilability.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import subprocess

# Thats where our cpps are currently
BASE_PATH = "vorkurs/"

BASE_PATH = "files/"

def find_all_cpp_files(findWorking):
vorkurs_path = pathlib.Path(BASE_PATH)
Expand All @@ -18,19 +17,23 @@ def find_all_cpp_files(findWorking):


def test_single_cpp_file(file_path, shouldCompile):
compile_status = subprocess.getoutput(f"g++ {file_path}")
compile_status = subprocess.getoutput(f"g++ {file_path} -w")

if (compile_status != "" and shouldCompile) or (
compile_status == "" and not shouldCompile
):
if compile_status != "" and shouldCompile:
print("\n" + 20 * "=")
print(f"Error in file {file_path}:\n")
print(compile_status)
print(20 * "=" + "\n")

return False
elif compile_status == "" and not shouldCompile:
print("\n" + 20 * "=")
print(f"File {file_path} compiles, but should be broken")
print("\n" + 20 * "=")

return True
return False

return True

def main():
error_count_working = 0
Expand All @@ -50,12 +53,13 @@ def main():
print(
f"::error::Found {error_count_working} non compiling files which should compile"
)
exit(1)


if error_count_broken > 0:
print(
f"::error:Found {error_count_broken} files that should be broken but compile"
f"::error::Found {error_count_broken} files that should be broken but compile"
)

if error_count_broken > 0 or error_count_working > 0:
exit(1)

exit(0)
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ dir: files/*
@echo "Dateien kopieren…"
@cp files/helloworld.cpp vorkurs/lektion01/. > /dev/null
@cp files/helloyou.cpp vorkurs/lektion03/. > /dev/null
@cp files/fehler1.cpp vorkurs/lektion04/. > /dev/null
@cp files/fehler2.cpp vorkurs/lektion04/. > /dev/null
@cp files/fehler3.cpp vorkurs/lektion04/. > /dev/null
@cp files/fehler4.cpp vorkurs/lektion04/. > /dev/null
@cp files/fehler5.cpp vorkurs/lektion04/. > /dev/null
@cp files/noImport_broken.cpp vorkurs/lektion04/. > /dev/null
@cp files/noSemicolon2_broken.cpp vorkurs/lektion04/. > /dev/null
@cp files/noBracket_broken.cpp vorkurs/lektion04/. > /dev/null
@cp files/wrongDirection_broken.cpp vorkurs/lektion04/. > /dev/null
@cp files/noSemicolon2_broken.cpp vorkurs/lektion04/. > /dev/null
@cp files/variablen.cpp vorkurs/lektion05/. > /dev/null
@cp files/arith1.cpp vorkurs/lektion07/. > /dev/null
@cp files/arith2.cpp vorkurs/lektion07/. > /dev/null
Expand Down
18 changes: 18 additions & 0 deletions files/array.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <iostream>

int main() {
// Hier initialisieren wir das Array
int numbers[5] = {1, 4, 3, 9, 100};

// Wir zählen ab 0, das 5. Element hat also den Index 4
int letzteZahl = numbers[4];

// So könnte man das Array in der Konsole ausgeben
std::cout << "Das Array beinhaltet die Zahlen" << std::endl;

for (int n = 0; n < 5; n++) {
std::cout << numbers[n] << " ";
}

return 0;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
29 changes: 16 additions & 13 deletions lektionen/errors_warnings.tex
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@

Nehmen wir z.B. mal folgendes Programm:

\inputcpp{fehler1.cpp}
\inputcpp{noImport\string_broken.cpp}

Wenn wir versuchen, dieses zu kompilieren, gibt uns \texttt{g++} folgendes aus:

\begin{textcode*}{label=g++ -o fehler1 fehler1.cpp}
fehler1.cpp: In function 'int main()':
fehler1.cpp:2:5: error: 'cout' is not a member of 'std'
fehler1.cpp:2:35: error: 'endl' is not a member of 'std'
\begin{textcode*}{label=g++ -o fehler1 noImport\_broken.cpp}
noImport\_broken.cpp: In function 'int main()':
noImport\_broken.cpp:2:5: error: 'cout' is not a member of 'std'
noImport\_broken.cpp:2:35: error: 'endl' is not a member of 'std'
\end{textcode*}

Je nach Compiler und Betriebssystem kann die Nachricht abweichen, im generellen ist der Fehler
aber immer auf das \texttt{std} bzw \texttt{cout} und \texttt{endl} zurückzuführen.

Wenn wir diese Fehlermeldung verstehen wollen, fangen wir immer ganz oben an,
egal wie viel Text uns der Compiler ausspucken mag. In diesem Fall sagt uns die
erste Zeile, in welcher Datei (\texttt{fehler1.cpp}) der Fehler aufgetreten ist
erste Zeile, in welcher Datei (\texttt{noImport\string_broken.cpp}) der Fehler aufgetreten ist
und in welcher Funktion (\texttt{int main()}). Die beiden Zeilen
danach sind sogar noch spezifischer: Sie enthalten zu Beginn den Dateinamen,
dann einen Doppelpunkt, gefolgt von einer Zeilennummer, gefolgt von einer
Expand All @@ -50,14 +53,14 @@

Der nächste sehr häufig vorkommende Fehler ist subtiler:

\inputcpp{fehler2.cpp}
\inputcpp{noSemicolon\string_broken.cpp}

Wenn wir versuchen, dies zu kompilieren, bekommen wir vom Compiler
entgegengespuckt:

\begin{textcode*}{label=g++ -o fehler2 fehler2.cpp}
fehler2.cpp: In function 'int main()':
fehler2.cpp:5:1: error: expected ';' before '}' token
\begin{textcode*}{label=g++ -o fehler2 noSemicolon\_broken.cpp}
noSemicolon\_broken.cpp: In function 'int main()':
noSemicolon\_broken.cpp:5:1: error: expected ';' before '\}' token
\end{textcode*}

Wiederum sagt uns die erste Zeile, in welcher Datei und Funktion der Fehler
Expand Down Expand Up @@ -88,8 +91,8 @@
korrekt arbeitet (schaut euch ggf. die bisher gezeigten Quellcodes an)?
\end{enumerate}

\inputcpp{fehler3.cpp}
\inputcpp{fehler4.cpp}
\inputcpp{noBracket\string_broken.cpp}
\inputcpp{wrongDirection\string_broken.cpp}

\begin{spiel}
\begin{enumerate}
Expand All @@ -103,7 +106,7 @@
\end{enumerate}
\end{spiel}

\inputcpp{fehler5.cpp}
\inputcpp{noSemicolon2\string_broken.cpp}

\textbf{Quiz 4}\\
\textit{Was hiervon sind Fehler, die dazu führen, dass eine Datei nicht kompiliert werden kann?}
Expand Down