glog icon indicating copy to clipboard operation
glog copied to clipboard

i build with bazel clang-tidy, loggging.h error: 'chrono' file not found [clang-diagnostic-error]

Open boluo250 opened this issue 2 years ago • 2 comments

image

**BUILD**
filegroup(
       name = "clang_tidy_config",
       data = [".clang-tidy"],
       visibility = ["//visibility:public"],
)

**WORKSPACE**
load(
    "@bazel_tools//tools/build_defs/repo:git.bzl",
    "git_repository",
)
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
git_repository(
       name = "bazel_clang_tidy",
       commit = "783aa523aafb4a6798a538c61e700b6ed27975a7",
       remote = "https://github.com/erenon/bazel_clang_tidy.git",
)
http_archive(
        name = "com_github_gflags_gflags",
        sha256 = "f6f4f932f5810deb229f16b82a41debaa0a0716670c0cd8ddea046f0bee72a4e",
        strip_prefix = "gflags-v2.1",
        url = "http://gitlab.tsingj.local/external/gflags/-/archive/v2.1/gflags-v2.1.tar.gz",
    )

git_repository(
       name = "com_github_google_glog",
       commit = "c515e1ae2fc8b36ca19362842f9347e9429be7ad",
       remote = "https://github.com/google/glog.git",
)

**.bazelrc** 
build:clang-tidy --aspects @bazel_clang_tidy//clang_tidy:clang_tidy.bzl%clang_tidy_aspect
build:clang-tidy --output_groups=report
build:clang-tidy --@bazel_clang_tidy//:clang_tidy_config=//:clang_tidy_config



**./es_cpp/BUILD**
cc_binary(
    name = "main-es1",
    srcs = ["testaaa.h"],
    deps = [
        "@com_github_google_glog//:glog",
    ],
    copts = [
        "-std=c++17",
    ],
    visibility = ["//visibility:public"],
)

**testaaa.h**
#include "glog/logging.h"

boluo250 avatar Jul 13 '22 07:07 boluo250

The very first error (invalid argument -std=c++17) indicates that you are compiling the sources probably as C not C++. Therefore, it is clear that including <chono> is not meaningful.

sergiud avatar Jul 14 '22 17:07 sergiud

I think you might need to rename testaaa.h to testaaa.cc to test this properly.

Some docs here: https://docs.bazel.build/versions/main/be/c-cpp.html#cc_binary.srcs

drigz avatar Jul 15 '22 23:07 drigz

I'm closing the issue since the cause is incorrect clang-tidy usage.

sergiud avatar Jan 23 '24 15:01 sergiud