roslint
roslint copied to clipboard
Unnamed function parameter mistaken for a C-style cast
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]
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.
It's the same with postfix increment operator:
TimeSpanHelper operator ++(int) {...}
The message is "Using C-Style cast. Use static_cast(...) instead"
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;
}