Skip to content

warning: circular header file dependency detected while including 'base.h' #4623

@ClausKlein

Description

@ClausKlein

I use

#==================================================
project(
    fmt
    VERSION 12.1.0.1
    DESCRIPTION "A modern formatting library"
    HOMEPAGE_URL https://fmt.dev/12.0/
    LANGUAGES CXX
)
#==================================================

Which this example:

// Header-only configuration test

#ifdef FMT_MODULE

#  ifdef FMT_IMPORT_STD
import std;
import std.compat;
#  else
#    include <string_view>
#  endif

import fmt;

#else

#  include "fmt/base.h"
#  include "fmt/ostream.h"

#endif

// NOLINTNEXTLINE(bugprone-exception-escape)
auto main() -> int
{
  constexpr std::string_view text {"constexpr"};
  fmt::print(text);
}

I got this clang-tidy errors:

Running clang-tidy for 1 files out of 31 in compilation database ...
[1/1][14.9s] /usr/local/Cellar/llvm/21.1.6/bin/clang-tidy -p=/Users/clausklein/Workspace/cpp/cxx20/fmt-module /Users/clausklein/Workspace/cpp/cxx20/fmt-module/tests/header-only-test.cc
error: missing '(' after '__has_feature' [clang-diagnostic-error]
/Users/clausklein/.cache/CPM/fmt/6226dc0d560c5dca8bcd81db09f7e2752ccb8cef/include/fmt/format.h:41:10: warning: circular header file dependency detected while including 'base.h', please check the include path [misc-header-include-cycle]
   41 | #include "base.h"
      |          ^
/Users/clausklein/.cache/CPM/fmt/6226dc0d560c5dca8bcd81db09f7e2752ccb8cef/include/fmt/base.h:3008:12: note: 'format.h' included from here
 3008 | #  include "format.h"
      |            ^
/Users/clausklein/Workspace/cpp/cxx20/fmt-module/tests/header-only-test.cc:16:12: note: 'base.h' included from here
   16 | #  include "fmt/base.h"
      |            ^
122455 warnings and 10 errors generated.
Error while processing /Users/clausklein/Workspace/cpp/cxx20/fmt-module/tests/header-only-test.cc.
Suppressed 122458 warnings (122454 in non-user code, 4 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
Found compiler error(s).

bash-5.3$ 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions