cppclean
cppclean copied to clipboard
Invalid "... not found in any directly included header"
Maybe I'm doing something wrong, but I don't see what that might be. :-/
Simple test:
- create
/tmp/include/test/inc.hpp
with this:
#pragma once
#include <vector>
#include <string_view>
namespace test {
std::vector<char> from_hex(const std::string_view& in);
}
- create
/tmp/src/test/hex.cpp
with this:
#include <test/inc.hpp>
namespace test {
std::vector<char> from_hex(const std::string_view& in) {
std::vector<char> result;
result.reserve(in.size() / 2 + 1);
return result;
}
}
-
g++ --std=c++17 -Wall -I /tmp/include/ -c -o /tmp/src/test/hex.o /tmp/src/test/hex.cpp
works without warnings - But
cppclean --include-path=/tmp/include /tmp/src/
complains
/tmp/src/test/hex.cpp:4: 'from_hex' not found in any directly #included header
What am I missing?
I ran into the same problem. I found that it was caused by including with angle-brackets instead of double quotes. I found two solutions:
- Change all angle-bracket includes like
#include <mylib/my_file.hpp>
to double quotes like#include "mylib/my_file.hpp"
, or - Use the
--include-path-non-system
option of cppclean:cppclean --include-path-non-system=/tmp/include /tmp/src/
Thanks. I think at the very least the error message is misleading.