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

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

Open
pmconrad opened this issue May 8, 2020 · 2 comments
Open

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

pmconrad opened this issue May 8, 2020 · 2 comments

Comments

@pmconrad
Copy link

pmconrad commented May 8, 2020

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?

@davidtrevelyan
Copy link

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/

@pmconrad
Copy link
Author

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

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

2 participants