cppclean icon indicating copy to clipboard operation
cppclean copied to clipboard

Invalid "... not found in any directly included header"

Open pmconrad opened this issue 4 years ago • 2 comments

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?

pmconrad avatar May 08 '20 08:05 pmconrad

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:

  1. Change all angle-bracket includes like #include <mylib/my_file.hpp> to double quotes like #include "mylib/my_file.hpp", or
  2. Use the --include-path-non-system option of cppclean: cppclean --include-path-non-system=/tmp/include /tmp/src/

davidtrevelyan avatar Nov 06 '20 16:11 davidtrevelyan

Thanks. I think at the very least the error message is misleading.

pmconrad avatar Nov 10 '20 07:11 pmconrad