author | František Kučera <franta-hg@frantovo.cz> |
Wed, 30 Oct 2024 22:08:49 +0100 | |
changeset 2 | 64777e5b619f |
parent 1 | 4502b1c7346d |
permissions | -rw-r--r-- |
franta-hg@1 | 1 |
# cpp-finally |
franta-hg@1 | 2 |
# Copyright © 2024 František Kučera (Frantovo.cz, GlobalCode.info) |
franta-hg@1 | 3 |
# |
franta-hg@1 | 4 |
# This program is free software: you can redistribute it and/or modify |
franta-hg@1 | 5 |
# it under the terms of the GNU General Public License as published by |
franta-hg@1 | 6 |
# the Free Software Foundation, version 3 of the License. |
franta-hg@1 | 7 |
# |
franta-hg@1 | 8 |
# This program is distributed in the hope that it will be useful, |
franta-hg@1 | 9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
franta-hg@1 | 10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
franta-hg@1 | 11 |
# GNU General Public License for more details. |
franta-hg@1 | 12 |
# |
franta-hg@1 | 13 |
# You should have received a copy of the GNU General Public License |
franta-hg@1 | 14 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
franta-hg@1 | 15 |
|
franta-hg@0 | 16 |
CXX ?= g++ |
franta-hg@0 | 17 |
CXXFLAGS ?= -O2 -g3 -ggdb -Wall -Wno-sign-compare |
franta-hg@0 | 18 |
CXXFLAGS += --std=c++20 |
franta-hg@0 | 19 |
CXXFLAGS += -fsanitize=undefined -fsanitize=address |
franta-hg@0 | 20 |
LDFLAGS ?= |
franta-hg@0 | 21 |
|
franta-hg@0 | 22 |
SRC = $(shell find -maxdepth 1 -name '*.cpp') |
franta-hg@0 | 23 |
BIN = $(shell find -maxdepth 1 -name '*.cpp' | xargs basename -s .cpp) |
franta-hg@0 | 24 |
|
franta-hg@0 | 25 |
all: $(BIN) |
franta-hg@0 | 26 |
|
franta-hg@0 | 27 |
.PHONY: all run clean |
franta-hg@0 | 28 |
|
franta-hg@0 | 29 |
clean: |
franta-hg@0 | 30 |
$(RM) $(BIN) |
franta-hg@0 | 31 |
|
franta-hg@0 | 32 |
run: $(BIN) |
franta-hg@0 | 33 |
@echo "\e[1;32mHappy path without exceptions:\e[0m" |
franta-hg@2 | 34 |
@for bin in $(BIN); do ./$$bin ; true; done |
franta-hg@0 | 35 |
@echo; echo |
franta-hg@0 | 36 |
@echo "\e[1;32mInterrupted by exceptions:\e[0m" |
franta-hg@2 | 37 |
@for bin in $(BIN); do ./$$bin fail; true; done |
franta-hg@0 | 38 |
|
franta-hg@0 | 39 |
$(BIN): $(SRC) |
franta-hg@0 | 40 |
$(CXX) $(CXXFLAGS) -o $(@) $(@).cpp $(LDFLAGS) |
franta-hg@0 | 41 |
|
franta-hg@0 | 42 |
# Blok finally při odchytávání výjimek: C++ vs. Java |
franta-hg@0 | 43 |
# https://blog.frantovo.cz/c/395/ |