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

cleaned up some array length related code #7283

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

firewave
Copy link
Collaborator

@firewave firewave commented Feb 4, 2025

No description provided.

test/helpers.h Outdated
@@ -246,4 +246,6 @@ struct LibraryHelper
static Library::Error loadxmldoc(Library &lib, const tinyxml2::XMLDocument& doc);
};

#define ARRAY_LEN(x) sizeof(x) / sizeof(x[0])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we use std::size()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is not available until C++17.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh jeez. Time to update... to C++20.

@@ -466,42 +466,42 @@ class TestCmdlineParser : public TestFixture {
void nooptions() {
REDIRECT;
const char * const argv[] = {"cppcheck"};
ASSERT_EQUALS_ENUM(CmdLineParser::Result::Exit, parser->parseFromArgs(1, argv));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is used in so many tests, maybe there should be a template overload that deduces the size?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, using a helper which does that would be better.

@firewave firewave marked this pull request as draft February 4, 2025 22:48
@firewave firewave force-pushed the array branch 2 times, most recently from dfa20f1 to e2f4223 Compare February 5, 2025 13:01
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.

2 participants