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

Unnamed function parameter mistaken for a C-style cast #54

Open
toliver opened this issue Sep 23, 2016 · 3 comments
Open

Unnamed function parameter mistaken for a C-style cast #54

toliver opened this issue Sep 23, 2016 · 3 comments

Comments

@toliver
Copy link

toliver commented Sep 23, 2016

In the following file:

/*********************************************************************
 *  Copyright (c) XXXXX, Inc.
 *********************************************************************/
void *testFunction(void * /*unused_param*/)
{
}

Cpplint returns:

test.cpp:4:  Using C-style cast.  Use reinterpret_cast<void *>(...) instead  [readability/casting] [4]

In cpplint.py here there is already a case to cover this. But the problem is that this condition only gets checked if the line ends (among other things) with the character {, as you can see here.

So that case would be correctly caught if we use

/*********************************************************************
 *  Copyright (c) XXXXX, Inc.
 *********************************************************************/
void *testFunction(void * /*unused_param*/) {
}

but then of course we get an error about the position of the braces.

test.cpp:4:  when starting a new scope, { should be on a line by itself  [whitespace/braces] [4]
@mikepurvis
Copy link
Member

Yes, this is a consequence of how we monkey patch cpplint.py to change it from Google's brace standard to the ROS one.

I'd welcome a patch to fix this.

@kmirny
Copy link

kmirny commented Mar 5, 2018

It's the same with postfix increment operator:
TimeSpanHelper operator ++(int) {...}
The message is "Using C-Style cast. Use static_cast(...) instead"

@ijnek
Copy link

ijnek commented Jun 11, 2021

I'm guessing there has been no patch for this issue. I'd suggest the C workaround for anyone that encounters this issue, to get the build without warnings and get cpplint to pass.

void *testFunction(SomeObject * p)
{
  (void) p;
}

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

No branches or pull requests

4 participants