Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xt-xcc unknown field 'obj' specified in initializer #33549

Closed
hongshui3000 opened this issue Mar 22, 2021 · 5 comments · Fixed by #33689
Closed

xt-xcc unknown field 'obj' specified in initializer #33549

hongshui3000 opened this issue Mar 22, 2021 · 5 comments · Fixed by #33689
Assignees
Labels
area: Toolchains Toolchains bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug

Comments

@hongshui3000
Copy link
Contributor

hongshui3000 commented Mar 22, 2021

Describe the bug
file:kernel.h

struct k_poll_event {
	/** PRIVATE - DO NOT TOUCH */
	sys_dnode_t _node;

	/** PRIVATE - DO NOT TOUCH */
	struct _poller *poller;

	/** optional user-specified tag, opaque, untouched by the API */
	uint32_t tag:8;

	/** bitfield of event types (bitwise-ORed K_POLL_TYPE_xxx values) */
	uint32_t type:_POLL_NUM_TYPES;

	/** bitfield of event states (bitwise-ORed K_POLL_STATE_xxx values) */
	uint32_t state:_POLL_NUM_STATES;

	/** mode of operation, from enum k_poll_modes */
	uint32_t mode:1;

	/** unused bits in 32-bit word */
	uint32_t unused:_POLL_EVENT_NUM_UNUSED_BITS;

	/** per-type data */
	union {                            -------------------------------------------------
		void *obj;                                                                                        
		struct k_poll_signal *signal;                                                            
		struct k_sem *sem;                                                                                                   
		struct k_fifo *fifo;                                                                         
		struct k_queue *queue;                                                             
	};   --------------------------------------------------------------------------
};

#define K_POLL_EVENT_INITIALIZER(_event_type, _event_mode, _event_obj) \
	{ \
	.poller = NULL, \
	.type = _event_type, \
	.state = K_POLL_STATE_NOT_READY, \
	.mode = _event_mode, \
	.unused = 0, \
	.obj = _event_obj, \--------------------------------------------------------->this
	}

#define K_POLL_EVENT_STATIC_INITIALIZER(_event_type, _event_mode, _event_obj, \
					event_tag) \
	{ \
	.tag = event_tag, \
	.type = _event_type, \
	.state = K_POLL_STATE_NOT_READY, \
	.mode = _event_mode, \
	.unused = 0, \
	.obj = _event_obj, \--------------------------------------------------------->this
	}

xt-xcc cannot recognize the obj object

Just change it to the following

#define K_POLL_EVENT_STATIC_INITIALIZER(_event_type, _event_mode, _event_obj, \
					event_tag) \
	{ \
	.tag = event_tag, \
	.type = _event_type, \
	.state = K_POLL_STATE_NOT_READY, \
	.mode = _event_mode, \
	.unused = 0, \
       { \--------------------------------------------------------->this
	.obj = _event_obj, \--------------------------------------------------------->this
        } \--------------------------------------------------------->this
	}

Logs and console output

[2/120] Building C object zephyr/subsys/bluetooth/host/CMakeFiles/subsys__bluetooth__host.dir/hci_core.c.obj
FAILED: zephyr/subsys/bluetooth/host/CMakeFiles/subsys__bluetooth__host.dir/hci_core.c.obj 
C:\usr\xtensa\XtDevTools\install\tools\RI-2020.5-win32\XtensaTools\bin\xt-xcc.exe -DBUILD_VERSION=zephyr-v2.4.0-1113-g0bcd66ac36d8 -DKERNEL -D_FORTIFY_SOURCE=2 -D__ZEPHYR__=1 -I../include -Izephyr/include/generated -I../soc/xtensa/ZC3827 -I../soc/xtensa/ZC3827/include -I../subsys/settings/include -I../subsys/bluetooth -IE:/work/rtos_work/zephyrproject/modules/crypto/tinycrypt/lib/include -IE:/work/rtos_work/zephyrproject/modules/hal/xtensa/include -IE:/work/rtos_work/zephyrproject/modules/hal/xtensa/zephyr/soc/ZC3827 -isystem ../lib/libc/minimal/include -Os -imacros E:/work/rtos_work/zephyrproject/zephyr/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -imacrosE:/work/rtos_work/zephyrproject/zephyr/include/toolchain/xcc_missing_defs.h -fms-extensions -imacros E:/work/rtos_work/zephyrproject/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-pic -fno-strict-overflow -ffunction-sections -fdata-sections -mlongcalls -std=c99 -MD -MT zephyr/subsys/bluetooth/host/CMakeFiles/subsys__bluetooth__host.dir/hci_core.c.obj -MF zephyr\subsys\bluetooth\host\CMakeFiles\subsys__bluetooth__host.dir\hci_core.c.obj.d -o zephyr/subsys/bluetooth/host/CMakeFiles/subsys__bluetooth__host.dir/hci_core.c.obj -c E:/work/rtos_work/zephyrproject/zephyr/subsys/bluetooth/host/hci_core.c
E:/work/rtos_work/zephyrproject/zephyr/subsys/bluetooth/host/hci_core.c: In function 'hci_tx_thread':
E:/work/rtos_work/zephyrproject/zephyr/subsys/bluetooth/host/hci_core.c:5217: error: unknown field 'obj' specified in initializer
E:/work/rtos_work/zephyrproject/zephyr/subsys/bluetooth/host/hci_core.c:5217: warning: missing braces around initializer
E:/work/rtos_work/zephyrproject/zephyr/subsys/bluetooth/host/hci_core.c:5217: warning: (near initialization for 'events[0].<anonymous>')
E:/work/rtos_work/zephyrproject/zephyr/subsys/bluetooth/host/hci_core.c: In function 'bt_le_per_adv_set_param':
E:/work/rtos_work/zephyrproject/zephyr/subsys/bluetooth/host/hci_core.c:7164: warning: comparison is always false due to limited range of data type      
[11/120] Building C object zephyr/subsys/bluetooth/host/CMakeFiles/subsys__bluetooth__host.dir/gatt.c.obj
ninja: build stopped: subcommand failed.

Environment (please complete the following information):

  • OS: (Windows)
  • Toolchain (xt-xcc)
@hongshui3000 hongshui3000 added the bug The issue is a bug, or the PR is fixing a bug label Mar 22, 2021
@carlescufi carlescufi changed the title XT-XCC unknown field 'obj' specified in initializer xt-xcc unknown field 'obj' specified in initializer Mar 23, 2021
@carlescufi carlescufi added area: Toolchains Toolchains priority: medium Medium impact/importance bug labels Mar 23, 2021
dcpleung added a commit to dcpleung/zephyr that referenced this issue Mar 24, 2021
XCC (which is based on GCC 4.2) needs the initializer of
one of the union elements to be enclosed in brackets.
So add them.

Fixes zephyrproject-rtos#33549

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
galak pushed a commit that referenced this issue Mar 26, 2021
XCC (which is based on GCC 4.2) needs the initializer of
one of the union elements to be enclosed in brackets.
So add them.

Fixes #33549

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
@aisri
Copy link

aisri commented Nov 1, 2023

@hongshui3000 @galak @dcpleung @carlescufi

sorry to resurface the discussion,

This fix triggers -Wc99-designator error with -Wall -Werror on xt-clang (clang-10)

OS: Fedora
Toolchain: xt-xcc

Can you suggest alternatives?

@dcpleung
Copy link
Member

dcpleung commented Nov 1, 2023

Maybe if you give the anonymous struct a name?

@aisri
Copy link

aisri commented Nov 2, 2023

@dcpleung Thank you for coming back.

ya! I did think about that. It will trigger a cascade of changes across the code base. Will that be a good thing do? please advise!

@dcpleung
Copy link
Member

dcpleung commented Nov 2, 2023

That will need an RFC for this kind of changes to the tree. You can go on Discord to initial the conversation.

@aisri
Copy link

aisri commented Nov 2, 2023

thanks for the tip. let me bring this conversation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Toolchains Toolchains bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants