gpt4 book ai didi

C++ - Chromium 指南样式冲突虚拟覆盖

转载 作者:行者123 更新时间:2023-11-28 01:33:28 24 4
gpt4 key购买 nike

我正在尝试手动编译 WebRTC 库的文件。所以我正在复制一个编译行

../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF ../../../object_files/plugin.o.d -DV8_DEPRECATION_WARNINGS -DNO_TCMALLOC -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DCHROMIUM_BUILD -DFIELDTRIAL_TESTING_ENABLED -DCR_XCODE_VERSION=0930 -DCR_CLANG_REVISION=\"328716-2\" -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORE=0 -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DWTF_USE_DYNAMIC_ANNOTATIONS=1 -DGOOGLE_PROTOBUF_NO_RTTI -DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER -DHAVE_PTHREAD -I../.. -Igen -I../../third_party/protobuf/src -I../../third_party -fno-strict-aliasing -fmerge-all-constants -fstack-protector-strong -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -fcolor-diagnostics -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -no-canonical-prefixes -arch x86_64 -O0 -fno-omit-frame-pointer -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -mmacosx-version-min=10.9.0 -fvisibility=hidden -Xclang -load -Xclang ../../third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.dylib -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang no-realpath -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Werror -Wall -Wno-unused-variable -Wunguarded-availability -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-covered-switch-default -Wno-unneeded-internal-declaration -Wno-inconsistent-missing-override -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-address-of-packed-member -Wno-unused-lambda-capture -Wno-user-defined-warnings -Wno-enum-compare-switch -Wno-null-pointer-arithmetic -Wno-ignored-pragma-optimize -Wno-unused-function -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -std=c++11 -stdlib=libc++ -fno-exceptions -fno-rtti -fvisibility-inlines-hidden -c ../../../source_files/plugin.cc -o ../../../object_files/plugin.o

关于 plugin.cc来自 protobuf 库的文件(不重要的部分被删除)

#include <google/protobuf/compiler/plugin.h>

#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/plugin.pb.h>
#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>


namespace google {
namespace protobuf {
namespace compiler {

class GeneratorResponseContext : public GeneratorContext {
public:
GeneratorResponseContext(
const Version& compiler_version,
CodeGeneratorResponse* response,
const std::vector<const FileDescriptor*>& parsed_files)
: compiler_version_(compiler_version),
response_(response),
parsed_files_(parsed_files) {}
virtual ~GeneratorResponseContext() {}

} // namespace compiler
} // namespace protobuf
} // namespace google

(我知道很多)我得到了矛盾的错误

../../../source_files/plugin.cc:72:39: error: [chromium-style] Overriding method must be marked with 'override' or 'final'.
virtual ~GeneratorResponseContext() {}
^
override
../../../source_files/plugin.cc:72:3: error: [chromium-style] 'virtual' will be redundant; 'override' implies 'virtual'.
virtual ~GeneratorResponseContext() {}
^~~~~~~~

我不想触及代码,因为它是由比我大得多的程序员完成的。问题似乎来自使用的定义标志。出现错误是因为该文件似乎不尊重 chromium 指南样式。此 chromium 指南样式在编译行中添加了标志 -DCLANG_REV。但我不知道为什么会出现这个错误,makefile 设法编译它,因为我只需要模仿 makefile 的行为,这应该也能正常工作。因此,如果您有任何想法,它将对我有很大帮助,谢谢!

最佳答案

I don't want to touch the code because it has been done by largely greater programmer than me.

我敢肯定,如果您使用像下面这样的 override 特殊指令来声明析构函数,那么程序员不会生气,反而会称赞您。

~GeneratorResponseContext() override {}

或者,您可以在一行中暂时禁用 clang-tidy:

virtual ~GeneratorResponseContext() {} // NOLINT

最好的情况是按照供应商的说明将 protobuf 库独立构建为静态库,并在您的项目中使用静态库。

关于C++ - Chromium 指南样式冲突虚拟覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50507672/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com