compile errors .... chromium-style #2680
Labels
kind: bug
release item: 🔨 further change
solution: proposed fix
a fix for the issue has been proposed and waits for confirmation
Milestone
I use OneFile ----> single_include/nlohmann/json.hpp
I use nlohmann::json 3.9.1. I compiled it on Windows 10Pro 64bit
I'm making a program that is based on the chrome source code. I do:
mytest.cc:
#include "json.hpp"
// for convenience
using json = nlohmann::json;
When I compile mytest.cc I get errors:
1 error:
json.hpp(2645,5): error: [chromium-style] virtual methods with non-empty bodies shouldn't be declared inline.
{
^
2,3,4 errors:
../../brave/vendor/bat-native-ads/src/bat/ads/internal/mytest/json.hpp(16417,9): error: [chromium-style] auto variable type must not deduce to a raw pointer type.
auto buffer_ptr = number_buffer.begin();
^~~~
auto*
../../brave/vendor/bat-native-ads/src/bat/ads/internal/mytest/json.hpp(16522,13): error: [chromium-style] auto variable type must not deduce to a raw pointer type.
const auto end = std::remove(number_buffer.begin(),
^~~~~~~~~~
auto* const
../../brave/vendor/bat-native-ads/src/bat/ads/internal/mytest/json.hpp(16532,13): error: [chromium-style] auto variable type must not deduce to a raw pointer type.
const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
^~~~~~~~~~
auto* const
4 errors generated.
2,3,4 solved:
json.hpp(16417,9)
- auto buffer_ptr = number_buffer.begin();
+ auto* buffer_ptr = number_buffer.begin();
json.hpp(16522,13)
- const auto end = std::remove(number_buffer.begin(),
+ auto* const end = std::remove(number_buffer.begin(),
json.hpp(16532,13)
- const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
+ auto* const dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
But 1 error not solved...
I found the following information ...
https://www.chromium.org/developers/coding-style/chromium-style-checker-errors
`
Virtual Method Out-of-lining
Virtual methods are almost never inlined in practice. Because of this, methods on a base class will be emitted in each translation unit that allocates the object or any subclasses that don't override that method. This is usually not a major gain, unless you have a wide class hierarchy in which case it can be a big win (http://codereview.chromium.org/5741001/). Since virtual methods will almost never be inlined anyway (because they'll need to go through vtable dispatch), there are almost no downsides.
If you get the error:
It's because you wrote something like this:
And can be fixed by out of lining the method that does work:
..... I comment 2643-2648:
/* JSON_HEDLEY_RETURNS_NON_NULL
const char* what() const noexcept override
{
return m.what();
}
*/
`
and json compiled & test json example is work ... but the sediment remains
The text was updated successfully, but these errors were encountered: