From 20cf6d11f6b633d3a587afca6dd0d70f709fc2cf Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 26 Jul 2023 23:03:42 -0500 Subject: [PATCH] Workaround: Clang compiler problems, add _clang_not_a_compile_time_constant_workaround_ define in Byte Dump program. CLang fails to handle this well and errors out with: "initializer element is not a compile-time constant". Provide a custom define _clang_not_a_compile_time_constant_workaround_ to be used as a work-around for the problematic CLang compiler. --- level_3/byte_dump/c/main/common/string.c | 27 +++++++++++++++++++-------- level_3/byte_dump/data/build/defines | 2 ++ level_3/byte_dump/data/build/settings | 1 + 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/level_3/byte_dump/c/main/common/string.c b/level_3/byte_dump/c/main/common/string.c index 2542d9c..3df6dd2 100644 --- a/level_3/byte_dump/c/main/common/string.c +++ b/level_3/byte_dump/c/main/common/string.c @@ -36,14 +36,25 @@ extern "C" { const f_string_static_t byte_dump_padding_8_s = macro_f_string_static_t_initialize_1(BYTE_DUMP_padding_8_s, 0, BYTE_DUMP_padding_8_s_length); const f_string_static_t byte_dump_padding_9_s = macro_f_string_static_t_initialize_1(BYTE_DUMP_padding_9_s, 0, BYTE_DUMP_padding_9_s_length); - const f_string_static_t byte_dump_padding_s[] = { - byte_dump_padding_9_s, - byte_dump_padding_3_s, - byte_dump_padding_4_s, - byte_dump_padding_4_s, - byte_dump_padding_9_s, - byte_dump_padding_4_s, - }; + #ifdef _clang_not_a_compile_time_constant_workaround_ + const f_string_static_t byte_dump_padding_s[6] = { + macro_f_string_static_t_initialize_1(BYTE_DUMP_padding_9_s, 0, BYTE_DUMP_padding_9_s_length), + macro_f_string_static_t_initialize_1(BYTE_DUMP_padding_3_s, 0, BYTE_DUMP_padding_3_s_length), + macro_f_string_static_t_initialize_1(BYTE_DUMP_padding_4_s, 0, BYTE_DUMP_padding_4_s_length), + macro_f_string_static_t_initialize_1(BYTE_DUMP_padding_4_s, 0, BYTE_DUMP_padding_4_s_length), + macro_f_string_static_t_initialize_1(BYTE_DUMP_padding_9_s, 0, BYTE_DUMP_padding_9_s_length), + macro_f_string_static_t_initialize_1(BYTE_DUMP_padding_4_s, 0, BYTE_DUMP_padding_4_s_length), + }; + #else + const f_string_static_t byte_dump_padding_s[] = { + byte_dump_padding_9_s, + byte_dump_padding_3_s, + byte_dump_padding_4_s, + byte_dump_padding_4_s, + byte_dump_padding_9_s, + byte_dump_padding_4_s, + }; + #endif #endif // _di_byte_dump_padding_s_ #ifndef _di_byte_dump_parameter_d_ diff --git a/level_3/byte_dump/data/build/defines b/level_3/byte_dump/data/build/defines index 490da41..d987e36 100644 --- a/level_3/byte_dump/data/build/defines +++ b/level_3/byte_dump/data/build/defines @@ -4,3 +4,5 @@ _di_thread_support_ Disables thread support. _pthread_attr_unsupported_ Disable non-portable functionality associated with pthread_attr. _pthread_sigqueue_unsupported_ Disable GNU specific sigqueue(). + +_clang_not_a_compile_time_constant_workaround_ Work around CLangs error "initializer element is not a compile-time constant". diff --git a/level_3/byte_dump/data/build/settings b/level_3/byte_dump/data/build/settings index d00a321..ca7f6fd 100644 --- a/level_3/byte_dump/data/build/settings +++ b/level_3/byte_dump/data/build/settings @@ -72,6 +72,7 @@ environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY L defines -D_libcap_legacy_only_ defines-threadless -D_di_thread_support_ defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ +defines-clang -D_clang_not_a_compile_time_constant_workaround_ flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces flags-thread -pthread -- 1.8.3.1