-
Notifications
You must be signed in to change notification settings - Fork 227
Description
Describe the bug
cFE compiles (with warnings about implicit function declarations), but linking the cfe_core executable errors out with undefined references to symbols CFE_SB_ValueToMsgId and CFE_SB_MsgIdToValue.
To Reproduce
Steps to reproduce the behavior:
-
Create a mission configuration. Modify global_build_options.cmake by adding the following two lines:
set(MISSION_INCLUDE_CCSDSEXT_HEADER TRUE)
set(MISSION_MSGID_V2 TRUE) -
Build cFS. The following warnings will be issued when compiling cfe_msg_msgid_v2.c:
[ 77%] Building C object msg/CMakeFiles/msg.dir/fsw/src/cfe_msg_msgid_v2.c.o
/home/dsa/lpnt_ws/dsa_lpnt_fsw/fsw/cFS/cfe/modules/msg/fsw/src/cfe_msg_msgid_v2.c: In function ‘CFE_MSG_GetMsgId’:
/home/dsa/lpnt_ws/dsa_lpnt_fsw/fsw/cFS/cfe/modules/msg/fsw/src/cfe_msg_msgid_v2.c:80:14: warning: implicit declaration of function ‘CFE_SB_ValueToMsgId’ [-Wimplicit-function-declaration]
80 | *MsgId = CFE_SB_ValueToMsgId(msgidval);
| ^~~~~~~~~~~~~~~~~~~
/home/dsa/lpnt_ws/dsa_lpnt_fsw/fsw/cFS/cfe/modules/msg/fsw/src/cfe_msg_msgid_v2.c: In function ‘CFE_MSG_SetMsgId’:
/home/dsa/lpnt_ws/dsa_lpnt_fsw/fsw/cFS/cfe/modules/msg/fsw/src/cfe_msg_msgid_v2.c:96:36: warning: implicit declaration of function ‘CFE_SB_MsgIdToValue’ [-Wimplicit-function-declaration]
96 | CFE_SB_MsgId_Atom_t msgidval = CFE_SB_MsgIdToValue(MsgId);
| ^~~~~~~~~~~~~~~~~~~
The following error will be reported at the link phase:
[100%] Linking C executable core-cpu1
/usr/bin/ld: ../msg/libmsg.a(cfe_msg_msgid_v2.c.o): in functionCFE_MSG_GetMsgId': cfe_msg_msgid_v2.c:(.text+0x8b): undefined reference toCFE_SB_ValueToMsgId'
/usr/bin/ld: ../msg/libmsg.a(cfe_msg_msgid_v2.c.o): in functionCFE_MSG_SetMsgId': cfe_msg_msgid_v2.c:(.text+0xd1): undefined reference toCFE_SB_MsgIdToValue'
collect2: error: ld returned 1 exit status
make[11]: *** [cpu1/CMakeFiles/core-cpu1.dir/build.make:199: cpu1/core-cpu1] Error 1 -
The bug occurs because the two functions are defined as 'static inline' in cfe_sb.h, which is not referenced in cfe_msg_msgid_v2.c, and because the C language prior to the C99 standard implicitly defines functions as
int fn_name(int). Simply adding#include "cfe_sb.h"fixes the problem.
Expected behavior
core-cpu1 should compile and link cleanly.
Code snips
See attached patch file.
System observed on:
- Hardware: VirtualBox 6.1.30 emulation of a generic x86-64 system on macOS 11.6.3
- OS: Ubuntu 20.04
- Compiler: GCC 9.3.0
- Versions: cFE tag v7.0.0-rc4, OSAL tag v6.0.0-rc4, PSP tag v1.6.0-rc4
Additional context
Reporter Info
Chuck Fry, QTS Inc., subcontractor to KBR Wyle on the ISRDS3 contract, at NASA ARC Code TI
chuck.fry@nasa.gov