diff --git a/code_snippets/appendix0a/appendix0a_15-004_type_traits.cpp b/code_snippets/appendix0a/appendix0a_15-004_type_traits.cpp index af6734ab2..73eae1301 100644 --- a/code_snippets/appendix0a/appendix0a_15-004_type_traits.cpp +++ b/code_snippets/appendix0a/appendix0a_15-004_type_traits.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2019. +// Copyright Christopher Kormanyos 2019 - 2023. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -7,6 +7,7 @@ // appendix0a_15-004_type_traits.cpp +#include #include #include #include diff --git a/code_snippets/chapter03/chapter03.sh b/code_snippets/chapter03/chapter03.sh index bd9f0bdf1..f059435b5 100755 --- a/code_snippets/chapter03/chapter03.sh +++ b/code_snippets/chapter03/chapter03.sh @@ -44,7 +44,9 @@ $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -O3 -m64 -fsanitize=address -fsa $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum ./chapter03_11-001_array.cpp -o ./bin/chapter03_11-001_array.exe $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum ./chapter03_12-001_basic_stl.cpp -o ./bin/chapter03_12-001_basic_stl.exe $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum ./chapter03_13-001_basic_stl_numeric.cpp -o ./bin/chapter03_13-001_basic_stl_numeric.exe +if [[ "$GCC" == "g++" ]]; then $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum ./chapter03_14-001_atomic_operations.cpp -o ./bin/chapter03_14-001_atomic_operations.exe +fi $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum ./chapter03_15-001_digit_separators.cpp -o ./bin/chapter03_15-001_digit_separators.exe $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum ./chapter03_15-002_digit_separators.cpp -o ./bin/chapter03_15-002_digit_separators.exe $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum ./chapter03_16-001_binary_literals.cpp -o ./bin/chapter03_16-001_binary_literals.exe @@ -65,6 +67,7 @@ $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -O3 -m64 -fsanitize=address -fsa $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum ./chapter03_22-001_mersenne_twister_19937.cpp -o ./bin/chapter03_22-001_mersenne_twister_19937.exe $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum ./chapter03_22-002_test_random_engines.cpp -o ./bin/chapter03_22-002_test_random_engines.exe +if [[ "$GCC" == "g++" ]]; then ls -la \ ./bin/chapter03_01-001_declare_locals.exe \ ./bin/chapter03_02-001_fixed_size_integer.exe \ @@ -106,6 +109,48 @@ ls -la \ ./bin/chapter03_21-001_span.exe \ ./bin/chapter03_22-001_mersenne_twister_19937.exe \ ./bin/chapter03_22-002_test_random_engines.exe +else +ls -la \ +./bin/chapter03_01-001_declare_locals.exe \ +./bin/chapter03_02-001_fixed_size_integer.exe \ +./bin/chapter03_02-002_prime_number.exe \ +./bin/chapter03_02-002a_explore_prime_numbers.exe \ +./bin/chapter03_03-001_bool_type.exe \ +./bin/chapter03_04-001_namespaces.exe \ +./bin/chapter03_04-002_anonymous_namespace.exe \ +./bin/chapter03_04-003_nested_namespace.exe \ +./bin/chapter03_05-001_basic_classes.exe \ +./bin/chapter03_06-001_basic_templates_add.exe \ +./bin/chapter03_06-002_basic_templates_xy_point.exe \ +./bin/chapter03_07-001_nullptr.exe \ +./bin/chapter03_08-001_constexpr.exe \ +./bin/chapter03_08-002_constexpr_more.exe \ +./bin/chapter03_08-003_constexpr_pown.exe \ +./bin/chapter03_09-001_static_assert.exe \ +./bin/chapter03_10-001_limits.exe \ +./bin/chapter03_11-001_array.exe \ +./bin/chapter03_12-001_basic_stl.exe \ +./bin/chapter03_13-001_basic_stl_numeric.exe \ +./bin/chapter03_15-001_digit_separators.exe \ +./bin/chapter03_15-002_digit_separators.exe \ +./bin/chapter03_16-001_binary_literals.exe \ +./bin/chapter03_16-002_binary_literals.exe \ +./bin/chapter03_17-001_user_defined_literals.exe \ +./bin/chapter03_17-002_user_defined_literals.exe \ +./bin/chapter03_17-003_user_defined_literals.exe \ +./bin/chapter03_17-004_user_defined_literals.exe \ +./bin/chapter03_17-005_user_defined_literals.exe \ +./bin/chapter03_17-006_user_defined_literals.exe \ +./bin/chapter03_18-001_alignment.exe \ +./bin/chapter03_18-002_alignment.exe \ +./bin/chapter03_19-001_final.exe \ +./bin/chapter03_19-002_final.exe \ +./bin/chapter03_20-001_alias.exe \ +./bin/chapter03_20-002_alias.exe \ +./bin/chapter03_21-001_span.exe \ +./bin/chapter03_22-001_mersenne_twister_19937.exe \ +./bin/chapter03_22-002_test_random_engines.exe +fi result_ls=$? diff --git a/code_snippets/chapter04/chapter04.sh b/code_snippets/chapter04/chapter04.sh index 16b8ab347..394003b00 100755 --- a/code_snippets/chapter04/chapter04.sh +++ b/code_snippets/chapter04/chapter04.sh @@ -31,9 +31,12 @@ $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -O3 -m64 -fsanitize=address -fsa $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum ./chapter04_07-001_led_hierarchy_uses_pwm.cpp -o ./bin/chapter04_07-001_led_hierarchy_uses_pwm.exe $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum ./chapter04_08-001_const_com_class.cpp -o ./bin/chapter04_08-001_const_com_class.exe $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum ./chapter04_08-002_nonconst_com_class.cpp -o ./bin/chapter04_08-002_nonconst_com_class.exe +if [[ "$GCC" == "g++" ]]; then $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum ./chapter04_08-003_poll_communication.cpp -o ./bin/chapter04_08-003_poll_communication.exe +fi +if [[ "$GCC" == "g++" ]]; then ls -la \ ./bin/chapter04_01-001_led_hierarchy.exe \ ./bin/chapter04_04-001_dynamic_polymorphism.exe \ @@ -43,6 +46,16 @@ ls -la \ ./bin/chapter04_08-001_const_com_class.exe \ ./bin/chapter04_08-002_nonconst_com_class.exe \ ./bin/chapter04_08-003_poll_communication.exe +else +ls -la \ +./bin/chapter04_01-001_led_hierarchy.exe \ +./bin/chapter04_04-001_dynamic_polymorphism.exe \ +./bin/chapter04_04-002_dynamic_polymorphism_cast.exe \ +./bin/chapter04_04-003_dynamic_polymorphism_ref.exe \ +./bin/chapter04_07-001_led_hierarchy_uses_pwm.exe \ +./bin/chapter04_08-001_const_com_class.exe \ +./bin/chapter04_08-002_nonconst_com_class.exe +fi result_all=$? diff --git a/code_snippets/chapter06/chapter06.sh b/code_snippets/chapter06/chapter06.sh index e7b1ef405..c35876e24 100755 --- a/code_snippets/chapter06/chapter06.sh +++ b/code_snippets/chapter06/chapter06.sh @@ -43,8 +43,10 @@ $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -Wconversion -Wsign-conversion $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -Wconversion -Wsign-conversion -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum ./chapter06_14-003_romable_initializer_list.cpp -o ./bin/chapter06_14-003_romable_initializer_list.exe $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -Wconversion -Wsign-conversion -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum ./chapter06_14-004_container_initializer_list.cpp -o ./bin/chapter06_14-004_container_initializer_list.exe $GCC -std=c++20 -Wall -Wextra -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum -I../../../boost-root ./chapter06_14-005_iterator_facade.cpp -o ./bin/chapter06_14-005_iterator_facade.exe +if [[ "$GCC" == "g++" ]]; then $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -Wconversion -Wsign-conversion -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum -pthread -lpthread ./chapter06_15-001_minimize_interrupt_frame.cpp -o ./bin/chapter06_15-001_minimize_interrupt_frame.exe $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -Wconversion -Wsign-conversion -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum -pthread -lpthread ./chapter06_15-002_minimize_interrupt_frame.cpp -o ./bin/chapter06_15-002_minimize_interrupt_frame.exe +fi $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -Wconversion -Wsign-conversion -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum ./chapter06_16-001_operator_new.cpp -o ./bin/chapter06_16-001_operator_new.exe $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -Wconversion -Wsign-conversion -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum ./chapter06_17-001_use_the_stl.cpp -o ./bin/chapter06_17-001_use_the_stl.exe $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -Wconversion -Wsign-conversion -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum ./chapter06_17-002_use_the_stl.cpp -o ./bin/chapter06_17-002_use_the_stl.exe @@ -53,6 +55,7 @@ $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -Wconversion -Wsign-conversion $GCC -std=$STD -Wall -Wextra -Wpedantic -Werror -Wconversion -Wsign-conversion -O3 -m64 -fsanitize=address -fsanitize=shift -fsanitize=shift-exponent -fsanitize=shift-base -fsanitize=integer-divide-by-zero -fsanitize=null -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=enum ./chapter06_21-001_rtti_typeinfo.cpp -o ./bin/chapter06_21-001_rtti_typeinfo.exe +if [[ "$GCC" == "g++" ]]; then ls -la \ ./bin/chapter06_01-001_crc32_mpeg2.exe \ ./bin/chapter06_03-001_mul_16x16to32.exe \ @@ -81,6 +84,34 @@ ls -la \ ./bin/chapter06_18-001_use_lambdas.exe \ ./bin/chapter06_18-002_use_lambdas.exe \ ./bin/chapter06_21-001_rtti_typeinfo.exe +else +ls -la \ +./bin/chapter06_01-001_crc32_mpeg2.exe \ +./bin/chapter06_03-001_mul_16x16to32.exe \ +./bin/chapter06_06-001_name_mangling.exe \ +./bin/chapter06_06-002_name_mangling_get_event.exe \ +./bin/chapter06_07-001_assembly_sequences.exe \ +./bin/chapter06_08-001_comments.exe \ +./bin/chapter06_09-001_typedef_reg_access.exe \ +./bin/chapter06_09-002_typedef_led_template.exe \ +./bin/chapter06_09-003_alias_reg_access.exe \ +./bin/chapter06_10-001_checksum_uint8_t.exe \ +./bin/chapter06_10-002_checksum_uint_fast8_t.exe \ +./bin/chapter06_11-001_scale_with_powers_of_two.exe \ +./bin/chapter06_12-001_mul_shift_and_add.exe \ +./bin/chapter06_13-001_adc_dimensioning.exe \ +./bin/chapter06_14-001_romable_string.exe \ +./bin/chapter06_14-002_romable_array.exe \ +./bin/chapter06_14-003_romable_initializer_list.exe \ +./bin/chapter06_14-004_container_initializer_list.exe \ +./bin/chapter06_14-005_iterator_facade.exe \ +./bin/chapter06_16-001_operator_new.exe \ +./bin/chapter06_17-001_use_the_stl.exe \ +./bin/chapter06_17-002_use_the_stl.exe \ +./bin/chapter06_18-001_use_lambdas.exe \ +./bin/chapter06_18-002_use_lambdas.exe \ +./bin/chapter06_21-001_rtti_typeinfo.exe +fi result_ls=$? diff --git a/code_snippets/chapter06/chapter06_17-001_use_the_stl.cpp b/code_snippets/chapter06/chapter06_17-001_use_the_stl.cpp index 8b238851e..b0955af04 100644 --- a/code_snippets/chapter06/chapter06_17-001_use_the_stl.cpp +++ b/code_snippets/chapter06/chapter06_17-001_use_the_stl.cpp @@ -8,6 +8,7 @@ // chapter06_17-001_use_the_stl.cpp #include +#include #include #include #include diff --git a/code_snippets/chapter06/chapter06_17-002_use_the_stl.cpp b/code_snippets/chapter06/chapter06_17-002_use_the_stl.cpp index 5b6c9f918..1dc49d2dc 100644 --- a/code_snippets/chapter06/chapter06_17-002_use_the_stl.cpp +++ b/code_snippets/chapter06/chapter06_17-002_use_the_stl.cpp @@ -8,6 +8,7 @@ // chapter06_17-002_use_the_stl.cpp #include +#include #include #include #include diff --git a/code_snippets/chapter06/chapter06_21-001_rtti_typeinfo.cpp b/code_snippets/chapter06/chapter06_21-001_rtti_typeinfo.cpp index 1a36f5d91..ec8aaabb0 100644 --- a/code_snippets/chapter06/chapter06_21-001_rtti_typeinfo.cpp +++ b/code_snippets/chapter06/chapter06_21-001_rtti_typeinfo.cpp @@ -7,6 +7,7 @@ // chapter06_21-001_rtti_typeinfo.cpp +#include #include #include #include