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

Replay: The number of elements in a char array can be obtained using SIZEOF #28169

Conversation

muramura
Copy link
Contributor

I think it's better to get the size using SIZEOF rather than a literal value.

@magicrub
Copy link
Contributor

even though this is correct in this case, the better solution is to use ARRAY_SIZE(). Anyone else have any preference of sizeof() vs ARRAY_SIZE()?

@peterbarker
Copy link
Contributor

even though this is correct in this case, the better solution is to use ARRAY_SIZE(). Anyone else have any preference of sizeof() vs ARRAY_SIZE()?

Using ARRAY_SIZE() consistently is probably a good idea. ARRAY_SIZE() will fail if you use it on something which isn't an array, sizeof() won't.

@peterbarker peterbarker force-pushed the AP_The_number_of_elements_in_a_char_array_can_be_obtained_using_SIZEOF branch from 76815ec to bd46c62 Compare September 24, 2024 02:58
@peterbarker
Copy link
Contributor

Changed this to ARRAY_SIZE and marked for MergeOnCIPass

@peterbarker peterbarker merged commit 8f58612 into ArduPilot:master Sep 24, 2024
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants