Skip to content

Conversation

@stephanosio
Copy link
Member

'k_thread_stack_t' and 'k_thread_entry_t' typedefs are forward-declared
in sys/arch_interface.h and, because this header is included by
arch/cpu.h, which is, in turn, included by kernel_includes.h, the
typedefs effectively get re-declared in kernel.h.

While this does not cause a compilation error when compiling with GCC
4.6 and above, GCC 4.5 and below strictly enforce the C99 standard and
do not allow redeclaration of the same typedef in the same scope.

This commit adds sys/arch_interface.h header inclusion checks in
kernel.h to skip declaration of the forward-declared typedefs.

Signed-off-by: Stephanos Ioannidis [email protected]

'k_thread_stack_t' and 'k_thread_entry_t' typedefs are forward-declared
in sys/arch_interface.h and, because this header is included by
arch/cpu.h, which is, in turn, included by kernel_includes.h, the
typedefs effectively get re-declared in kernel.h.

While this does not cause a compilation error when compiling with GCC
4.6 and above, GCC 4.5 and below strictly enforce the C99 standard and
do not allow redeclaration of the same typedef in the same scope.

This commit adds sys/arch_interface.h header inclusion checks in
kernel.h to skip declaration of the forward-declared typedefs.

Signed-off-by: Stephanos Ioannidis <[email protected]>
@stephanosio stephanosio added the area: Portability Standard compliant code, toolchain abstraction label Nov 12, 2019
@zephyrbot zephyrbot added the area: API Changes to public APIs label Nov 12, 2019
@stephanosio
Copy link
Member Author

Sample compilation error in GCC 4.5.1 due to redeclaration of the same typedefs:

[7/131] Building C object zephyr/CMakeFiles/offsets.dir/arch/tc32/core/offsets/offsets.c.obj
FAILED: zephyr/CMakeFiles/offsets.dir/arch/tc32/core/offsets/offsets.c.obj
ccache /opt/tc32/bin/tc32-elf-gcc -DBUILD_VERSION=v2.1.0-rc1-94-g1a5d7d13d8d8 -DCHIP_TYPE=7 -DKERNEL -D_FORTIFY_SOURCE=2 -D__ZEPHYR__=1 -I../../../../../kernel/include -I../../../../../arch/tc32/include -I../../../../../include -I../../../../../include/drivers -Izephyr/include/generated -I../../../../../soc/tc32/tlsr/tlsr826x -I../../../../../soc/tc32/tlsr/include -I../../../../../ext/hal/telink/.. -I../../../../../ext/hal/tmsis/include -I../../../../../subsys/testsuite/include -I../../../../../subsys/testsuite/ztest/include -isystem ../../../../../lib/libc/minimal/include -isystem /opt/tc32/lib/gcc/tc32-elf/4.5.1.tc32-elf-1.5/include -isystem /opt/tc32/lib/gcc/tc32-elf/4.5.1.tc32-elf-1.5/include-fixed -Os -imacros/home/stephanos/Dev/zephyr-stephanos/zephyr/tests/kernel/threads/thread_apis/build_tc32/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -imacros/home/stephanos/Dev/zephyr-stephanos/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Werror=implicit-int -fno-jump-tables -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -ffunction-sections -fdata-sections -std=gnu99 -nostdinc -MD -MT zephyr/CMakeFiles/offsets.dir/arch/tc32/core/offsets/offsets.c.obj -MF zephyr/CMakeFiles/offsets.dir/arch/tc32/core/offsets/offsets.c.obj.d -o zephyr/CMakeFiles/offsets.dir/arch/tc32/core/offsets/offsets.c.obj   -c /home/stephanos/Dev/zephyr-stephanos/zephyr/arch/tc32/core/offsets/offsets.c
In file included from /home/stephanos/Dev/zephyr-stephanos/zephyr/arch/tc32/core/offsets/offsets.c:25:0:
../../../../../include/kernel.h:367:40: error: redefinition of typedef 'k_thread_stack_t'
../../../../../include/sys/arch_interface.h:44:40: note: previous declaration of 'k_thread_stack_t' was here
../../../../../include/kernel.h:387:16: error: redefinition of typedef 'k_thread_entry_t'
../../../../../include/sys/arch_interface.h:46:16: note: previous declaration of 'k_thread_entry_t' was here
ninja: build stopped: subcommand failed.

@stephanosio
Copy link
Member Author

Closing this PR as #21018 removed the duplicate definitions.

@stephanosio stephanosio deleted the fix_compat_typedef_redef branch April 23, 2020 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: API Changes to public APIs area: Portability Standard compliant code, toolchain abstraction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants