升级了MacOS 10.15 Beta版,结果编译 CockroachDB 遇到了问题。
[ 0%] Building CXX object CMakeFiles/rocksdb.dir/db/builder.cc.o [ 3%] Building CXX object CMakeFiles/rocksdb.dir/db/column_family.cc.o [ 3%] Building CXX object CMakeFiles/rocksdb.dir/db/compacted_db_impl.cc.o [ 3%] Building CXX object CMakeFiles/rocksdb.dir/db/compaction.cc.o In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/column_family.cc:24: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h:23: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h:24: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:111:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] WAL_FILE_BYTES, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:190:3: note: previous declaration is here WAL_FILE_BYTES, // Number of bytes written to WAL ^ In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/column_family.cc:24: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h:23: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h:24: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:112:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] WAL_FILE_SYNCED, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:189:3: note: previous declaration is here WAL_FILE_SYNCED, // Number of times WAL sync is done ^ In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/column_family.cc:24: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h:23: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h:24: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:113:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] BYTES_WRITTEN, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:126:3: note: previous declaration is here BYTES_WRITTEN, ^ In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/column_family.cc:24: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h:23: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h:24: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:114:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] NUMBER_KEYS_WRITTEN, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:119:3: note: previous declaration is here NUMBER_KEYS_WRITTEN, ^ In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/column_family.cc:24: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h:23: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h:24: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:115:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] WRITE_DONE_BY_OTHER, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:195:3: note: previous declaration is here WRITE_DONE_BY_OTHER, // Equivalent to writes done for others ^ In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/column_family.cc:24: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h:23: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h:24: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:116:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] WRITE_DONE_BY_SELF, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:194:3: note: previous declaration is here WRITE_DONE_BY_SELF, ^ In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/column_family.cc:24: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h:23: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h:24: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:117:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] WRITE_WITH_WAL, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:197:3: note: previous declaration is here WRITE_WITH_WAL, // Number of Write calls that request WAL ^ In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.cc:7: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.h:8: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h:23: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h:24: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:111:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] WAL_FILE_BYTES, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:190:3: note: previous declaration is here WAL_FILE_BYTES, // Number of bytes written to WAL ^ In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.cc:7: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.h:8: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h:23: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h:24: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:112:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] WAL_FILE_SYNCED, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:189:3: note: previous declaration is here WAL_FILE_SYNCED, // Number of times WAL sync is done ^ In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.cc:7: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.h:8: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h:23: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h:24: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:113:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] BYTES_WRITTEN, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:126:3: note: previous declaration is here BYTES_WRITTEN, ^ In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.cc:7: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.h:8: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h:23: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h:24: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:114:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] NUMBER_KEYS_WRITTEN, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:119:3: note: previous declaration is here NUMBER_KEYS_WRITTEN, ^ In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.cc:7: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.h:8: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h:23: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h:24: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:115:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] WRITE_DONE_BY_OTHER, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:195:3: note: previous declaration is here WRITE_DONE_BY_OTHER, // Equivalent to writes done for others ^ In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.cc:7: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.h:8: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h:23: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h:24: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:116:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] WRITE_DONE_BY_SELF, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:194:3: note: previous declaration is here WRITE_DONE_BY_SELF, ^ In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.cc:7: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compacted_db_impl.h:8: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/db_impl.h:23: In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/compaction_job.h:24: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:117:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] WRITE_WITH_WAL, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:197:3: note: previous declaration is here WRITE_WITH_WAL, // Number of Write calls that request WAL ^ In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/builder.cc:19: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:111:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] WAL_FILE_BYTES, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:190:3: note: previous declaration is here WAL_FILE_BYTES, // Number of bytes written to WAL ^ In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/builder.cc:19: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:112:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] WAL_FILE_SYNCED, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:189:3: note: previous declaration is here WAL_FILE_SYNCED, // Number of times WAL sync is done ^ In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/builder.cc:19: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:113:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] BYTES_WRITTEN, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:126:3: note: previous declaration is here BYTES_WRITTEN, ^ In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/builder.cc:19: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:114:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] NUMBER_KEYS_WRITTEN, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:119:3: note: previous declaration is here NUMBER_KEYS_WRITTEN, ^ In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/builder.cc:19: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:115:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] WRITE_DONE_BY_OTHER, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:195:3: note: previous declaration is here WRITE_DONE_BY_OTHER, // Equivalent to writes done for others ^ In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/builder.cc:19: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:116:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] WRITE_DONE_BY_SELF, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:194:3: note: previous declaration is here WRITE_DONE_BY_SELF, ^ In file included from /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/builder.cc:19: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/db/internal_stats.h:117:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow] WRITE_WITH_WAL, ^ /usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach/c-deps/rocksdb/include/rocksdb/statistics.h:197:3: note: previous declaration is here WRITE_WITH_WAL, // Number of Write calls that request WAL ^ 7 errors generated. gmake[5]: *** [CMakeFiles/rocksdb.dir/build.make:102: CMakeFiles/rocksdb.dir/db/builder.cc.o] Error 1 gmake[5]: *** Waiting for unfinished jobs.... 7 errors generated. gmake[5]: *** [CMakeFiles/rocksdb.dir/build.make:141: CMakeFiles/rocksdb.dir/db/compacted_db_impl.cc.o] Error 1 7 errors generated. gmake[5]: *** [CMakeFiles/rocksdb.dir/build.make:128: CMakeFiles/rocksdb.dir/db/column_family.cc.o] Error 1 gmake[4]: *** [CMakeFiles/Makefile2:4104: CMakeFiles/rocksdb.dir/all] Error 2 gmake[3]: *** [CMakeFiles/Makefile2:4115: CMakeFiles/rocksdb.dir/rule] Error 2 gmake[2]: *** [Makefile:1475: rocksdb] Error 2 gmake[1]: *** [Makefile:662: /usr/ports/databases/cockroach/work/cockroach-v19.1.1/native/x86_64-unknown-freebsd12.0/rocksdb/librocksdb.a] Error 2 gmake[1]: Leaving directory '/usr/ports/databases/cockroach/work/cockroach-v19.1.1/src/github.com/cockroachdb/cockroach' gmake: *** [Makefile:6: buildoss] Error 2 gmake: Leaving directory '/usr/ports/databases/cockroach/work/cockroach-v19.1.1' *** Error code 2 Stop. make: stopped in /usr/ports/databases/cockroach
MacOS 使用的 C 语言编译器是 llvm 下的 clang,所有的 gcc 的使用都会被链接到 clang 的使用上。
比如检查 gcc 版本
$ gcc -v Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1 Apple clang version 11.0.0 (clang-1100.0.33.8) Target: x86_64-apple-darwin19.0.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin
显示的就是 clang 的版本了。目前我的机器上的 clang 是 11.0.0
出现上面问题的原因是 clang 在8.0版本后对于代码的要求更为严格,有一种特殊的情况被判定为错误,无法正常编译。
报错信息中的 shadow 指的是函数内定义了和传入参数同名的变量,这就是 clang 拒绝的情况。
自习看报错信息,可以看到这些错误都发生在 rocksdb 文件夹下。到目前为止,rocksdb 都没有要改一下代码的意思,因为又不是不能用。
编译的时候可以加上标签 -Wno-error= 让包含特定信息的错误强行不报错。
更改 /rocksdb/CMakeLists.txt 文件,diff 形式(如果是 CockroachDB 的工程,该文件在 /cockroach/c-deps/ 文件夹下):
option(FAIL_ON_WARNINGS "Treat compile warnings as errors" ON) if(FAIL_ON_WARNINGS) if(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX") else() # assume GCC - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error") endif() endif()
修改 /rocksdb/Makefile 文件:
ifndef DISABLE_WARNING_AS_ERROR - WARNING_FLAGS += -Werror + WARNING_FLAGS += # -Werror endif
参考: