Skip to content

Remove ATOMIC_VAR_INIT#556

Merged
sloretz merged 2 commits intorollingfrom
sloretz__remove_ATOMIC_VAR_INIT
Apr 21, 2026
Merged

Remove ATOMIC_VAR_INIT#556
sloretz merged 2 commits intorollingfrom
sloretz__remove_ATOMIC_VAR_INIT

Conversation

@sloretz
Copy link
Copy Markdown
Contributor

@sloretz sloretz commented Apr 21, 2026

Description

This fixes a new compile error on Ubuntu Resolute. The ATOMIC_VAR_INIT macro was deprecated in C17 and removed in C23. Lyrical targets C17, so I'm not 100% sure why the macro dissapeared. My best guess is CMake decided C23 "satisfies" the requirement for C17 features, and is using that.

In file included from /workspaces/lyrical/src/ros2/rcutils/src/filesystem.c:42:
/workspaces/lyrical/src/ros2/rcutils/src/filesystem.c: In function ‘rcutils_dir_iter_next’:
/workspaces/lyrical/src/ros2/rcutils/src/filesystem.c:478:67: warning: statement with no effect [-Wunused-value]
  478 |   RCUTILS_CHECK_FOR_NULL_WITH_MSG(iter->state, "iter is invalid", false);
      |                                                                   ^~~~~
/workspaces/lyrical/src/ros2/rcutils/include/rcutils/error_handling.h:215:7: note: in definition of macro ‘RCUTILS_CHECK_FOR_NULL_WITH_MSG’
  215 |       error_statement; \
      |       ^~~~~~~~~~~~~~~
/workspaces/lyrical/src/ros2/rcutils/src/testing/fault_injection.c:19:63: error: implicit declaration of function ‘ATOMIC_VAR_INIT’; did you mean ‘ATOMIC_FLAG_INIT’? [-Wimplicit-function-declaration]
   19 | static atomic_int_least64_t g_rcutils_fault_injection_count = ATOMIC_VAR_INIT(-1);
      |                                                               ^~~~~~~~~~~~~~~
      |                                                               ATOMIC_FLAG_INIT
/workspaces/lyrical/src/ros2/rcutils/src/testing/fault_injection.c:19:63: error: initializer element is not constant
gmake[2]: *** [CMakeFiles/rcutils.dir/build.make:443: CMakeFiles/rcutils.dir/src/testing/fault_injection.c.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
gmake[1]: *** [CMakeFiles/Makefile2:294: CMakeFiles/rcutils.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2

Is this user-facing behavior change?

no

Did you use Generative AI?

I used gemini to research the replacement

Additional Information

Docs that talk about why ATOMIC_VAR_INIT is replaced with normal initialization: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2886.htm

Signed-off-by: Shane Loretz <sloretz@intrinsic.ai>
@sloretz sloretz self-assigned this Apr 21, 2026
@sloretz
Copy link
Copy Markdown
Contributor Author

sloretz commented Apr 21, 2026

CI (testing just rcutils)

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

Signed-off-by: Shane Loretz <sloretz@intrinsic.ai>
@sloretz
Copy link
Copy Markdown
Contributor Author

sloretz commented Apr 21, 2026

CI Attempt 2 with hopefully a fix for Windows

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@sloretz sloretz merged commit f40bb9f into rolling Apr 21, 2026
3 checks passed
@sloretz sloretz deleted the sloretz__remove_ATOMIC_VAR_INIT branch April 21, 2026 20:51
Copy link
Copy Markdown
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this replaces #554 (i actually think that this PR is the correct), and closes #554

@fujitatomoya
Copy link
Copy Markdown
Collaborator

correction, this closes #553

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants