[BUG] missing header files
Problem:
Failed to compile because of missing some header files.
My compile log:
- Missing
<string>
inconfig.h
In file included from /home/sisabyss/git/db2024/rmdb/src/replacer/lru_replacer.h:17,
from /home/sisabyss/git/db2024/rmdb/src/replacer/lru_replacer.cpp:11:
/home/sisabyss/git/db2024/rmdb/src/common/config.h:49:19: 错误:‘string’不是命名空间‘std’中的一个类型名
49 | static const std::string LOG_FILE_NAME = "db.log";
| ^~~~~~
/home/sisabyss/git/db2024/rmdb/src/common/config.h:15:1: 附注:‘std::string’ is defined in header ‘<string>’; this is probably fixable by adding ‘#include <string>’
14 | #include <chrono>
+++ |+#include <string>
15 | #include <cstdint>
/home/sisabyss/git/db2024/rmdb/src/common/config.h:52:19: 错误:‘string’不是命名空间‘std’中的一个类型名
52 | static const std::string REPLACER_TYPE = "LRU";
| ^~~~~~
/home/sisabyss/git/db2024/rmdb/src/common/config.h:52:14: 附注:‘std::string’ is defined in header ‘<string>’; this is probably fixable by adding ‘#include <string>’
52 | static const std::string REPLACER_TYPE = "LRU";
| ^~~
/home/sisabyss/git/db2024/rmdb/src/common/config.h:54:19: 错误:‘string’不是命名空间‘std’中的一个类型名
54 | static const std::string DB_META_NAME = "db.meta";
| ^~~~~~
/home/sisabyss/git/db2024/rmdb/src/common/config.h:54:14: 附注:‘std::string’ is defined in header ‘<string>’; this is probably fixable by adding ‘#include <string>’
54 | static const std::string DB_META_NAME = "db.meta";
- Missing
<memory>
intransaction.h
In file included from /home/sisabyss/git/db2024/rmdb/src/index/ix_index_handle.h:14,
from /home/sisabyss/git/db2024/rmdb/src/index/ix_index_handle.cpp:11:
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:53:17: 错误:‘shared_ptr’ in namespace ‘std’ does not name a template type
53 | inline std::shared_ptr<std::deque<WriteRecord *>> get_write_set() { return write_set_; }
| ^~~~~~~~~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:20:1: 附注:‘std::shared_ptr’ is defined in header ‘<memory>’; this is probably fixable by adding ‘#include <memory>’
19 | #include "txn_defs.h"
+++ |+#include <memory>
20 |
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:56:17: 错误:‘shared_ptr’ in namespace ‘std’ does not name a template type
56 | inline std::shared_ptr<std::deque<Page*>> get_index_deleted_page_set() { return index_deleted_page_set_; }
| ^~~~~~~~~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:56:12: 附注:‘std::shared_ptr’ is defined in header ‘<memory>’; this is probably fixable by adding ‘#include <memory>’
56 | inline std::shared_ptr<std::deque<Page*>> get_index_deleted_page_set() { return index_deleted_page_set_; }
| ^~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:59:17: 错误:‘shared_ptr’ in namespace ‘std’ does not name a template type
59 | inline std::shared_ptr<std::deque<Page*>> get_index_latch_page_set() { return index_latch_page_set_; }
| ^~~~~~~~~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:59:12: 附注:‘std::shared_ptr’ is defined in header ‘<memory>’; this is probably fixable by adding ‘#include <memory>’
59 | inline std::shared_ptr<std::deque<Page*>> get_index_latch_page_set() { return index_latch_page_set_; }
| ^~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:62:17: 错误:‘shared_ptr’ in namespace ‘std’ does not name a template type
62 | inline std::shared_ptr<std::unordered_set<LockDataId>> get_lock_set() { return lock_set_; }
| ^~~~~~~~~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:62:12: 附注:‘std::shared_ptr’ is defined in header ‘<memory>’; this is probably fixable by adding ‘#include <memory>’
62 | inline std::shared_ptr<std::unordered_set<LockDataId>> get_lock_set() { return lock_set_; }
| ^~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:73:10: 错误:‘shared_ptr’ in namespace ‘std’ does not name a template type
73 | std::shared_ptr<std::deque<WriteRecord *>> write_set_; // 事务包含的所有写操作
| ^~~~~~~~~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:73:5: 附注:‘std::shared_ptr’ is defined in header ‘<memory>’; this is probably fixable by adding ‘#include <memory>’
73 | std::shared_ptr<std::deque<WriteRecord *>> write_set_; // 事务包含的所有写操作
| ^~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:74:10: 错误:‘shared_ptr’ in namespace ‘std’ does not name a template type
74 | std::shared_ptr<std::unordered_set<LockDataId>> lock_set_; // 事务申请的所有锁
| ^~~~~~~~~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:74:5: 附注:‘std::shared_ptr’ is defined in header ‘<memory>’; this is probably fixable by adding ‘#include <memory>’
74 | std::shared_ptr<std::unordered_set<LockDataId>> lock_set_; // 事务申请的所有锁
| ^~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:75:10: 错误:‘shared_ptr’ in namespace ‘std’ does not name a template type
75 | std::shared_ptr<std::deque<Page*>> index_latch_page_set_; // 维护事务执行过程中加锁的索引页面
| ^~~~~~~~~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:75:5: 附注:‘std::shared_ptr’ is defined in header ‘<memory>’; this is probably fixable by adding ‘#include <memory>’
75 | std::shared_ptr<std::deque<Page*>> index_latch_page_set_; // 维护事务执行过程中加锁的索引页面
| ^~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:76:10: 错误:‘shared_ptr’ in namespace ‘std’ does not name a template type
76 | std::shared_ptr<std::deque<Page*>> index_deleted_page_set_; // 维护事务执行过程中删除的索引页面
| ^~~~~~~~~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:76:5: 附注:‘std::shared_ptr’ is defined in header ‘<memory>’; this is probably fixable by adding ‘#include <memory>’
76 | std::shared_ptr<std::deque<Page*>> index_deleted_page_set_; // 维护事务执行过程中删除的索引页面
| ^~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h: In constructor ‘Transaction::Transaction(txn_id_t, IsolationLevel)’:
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:25:9: 错误:‘write_set_’在此作用域中尚未声明
25 | write_set_ = std::make_shared<std::deque<WriteRecord *>>();
| ^~~~~~~~~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:25:27: 错误:‘make_shared’不是‘std’的成员
25 | write_set_ = std::make_shared<std::deque<WriteRecord *>>();
| ^~~~~~~~~~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:25:27: 附注:‘std::make_shared’ is defined in header ‘<memory>’; this is probably fixable by adding ‘#include <memory>’
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:25:63: 错误:expected primary-expression before ‘>’ token
25 | write_set_ = std::make_shared<std::deque<WriteRecord *>>();
| ^~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:25:66: 错误:expected primary-expression before ‘)’ token
25 | write_set_ = std::make_shared<std::deque<WriteRecord *>>();
| ^
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:26:9: 错误:‘lock_set_’在此作用域中尚未声明
26 | lock_set_ = std::make_shared<std::unordered_set<LockDataId>>();
| ^~~~~~~~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:26:26: 错误:‘make_shared’不是‘std’的成员
26 | lock_set_ = std::make_shared<std::unordered_set<LockDataId>>();
| ^~~~~~~~~~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:26:26: 附注:‘std::make_shared’ is defined in header ‘<memory>’; this is probably fixable by adding ‘#include <memory>’
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:26:67: 错误:expected primary-expression before ‘>’ token
26 | lock_set_ = std::make_shared<std::unordered_set<LockDataId>>();
| ^~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:26:70: 错误:expected primary-expression before ‘)’ token
26 | lock_set_ = std::make_shared<std::unordered_set<LockDataId>>();
| ^
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:27:9: 错误:‘index_latch_page_set_’ was not declared in this scope; did you mean ‘append_index_latch_page_set’?
27 | index_latch_page_set_ = std::make_shared<std::deque<Page *>>();
| ^~~~~~~~~~~~~~~~~~~~~
| append_index_latch_page_set
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:27:38: 错误:‘make_shared’不是‘std’的成员
27 | index_latch_page_set_ = std::make_shared<std::deque<Page *>>();
| ^~~~~~~~~~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:27:38: 附注:‘std::make_shared’ is defined in header ‘<memory>’; this is probably fixable by adding ‘#include <memory>’
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:27:67: 错误:expected primary-expression before ‘>’ token
27 | index_latch_page_set_ = std::make_shared<std::deque<Page *>>();
| ^~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:27:70: 错误:expected primary-expression before ‘)’ token
27 | index_latch_page_set_ = std::make_shared<std::deque<Page *>>();
| ^
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:28:9: 错误:‘index_deleted_page_set_’在此作用域中尚未声明
28 | index_deleted_page_set_ = std::make_shared<std::deque<Page*>>();
| ^~~~~~~~~~~~~~~~~~~~~~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:28:40: 错误:‘make_shared’不是‘std’的成员
28 | index_deleted_page_set_ = std::make_shared<std::deque<Page*>>();
| ^~~~~~~~~~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:28:40: 附注:‘std::make_shared’ is defined in header ‘<memory>’; this is probably fixable by adding ‘#include <memory>’
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:28:68: 错误:expected primary-expression before ‘>’ token
28 | index_deleted_page_set_ = std::make_shared<std::deque<Page*>>();
| ^~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:28:71: 错误:expected primary-expression before ‘)’ token
28 | index_deleted_page_set_ = std::make_shared<std::deque<Page*>>();
| ^
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h: In member function ‘void Transaction::append_write_record(WriteRecord*)’:
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:54:66: 错误:‘write_set_’在此作用域中尚未声明
54 | inline void append_write_record(WriteRecord* write_record) { write_set_->push_back(write_record); }
| ^~~~~~~~~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h: In member function ‘void Transaction::append_index_deleted_page(Page*)’:
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:57:57: 错误:‘index_deleted_page_set_’在此作用域中尚未声明
57 | inline void append_index_deleted_page(Page* page) { index_deleted_page_set_->push_back(page); }
| ^~~~~~~~~~~~~~~~~~~~~~~
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h: In member function ‘void Transaction::append_index_latch_page_set(Page*)’:
/home/sisabyss/git/db2024/rmdb/src/transaction/transaction.h:60:59: 错误:‘index_latch_page_set_’ was not declared in this scope; did you mean ‘append_index_latch_page_set’?
60 | inline void append_index_latch_page_set(Page* page) { index_latch_page_set_->push_back(page); }
| ^~~~~~~~~~~~~~~~~~~~~
| append_index_latch_page_set
- Missing
<stdio.h>
inrmdb.cpp
In file included from /usr/include/readline/history.h:36,
from /home/sisabyss/git/db2024/rmdb/src/rmdb.cpp:12:
/usr/include/readline/rltypedefs.h:71:13: 错误:typedef ‘rl_getc_func_t’ is initialized (use ‘decltype’ instead)
71 | typedef int rl_getc_func_t (FILE *);
| ^~~~~~~~~~~~~~
/usr/include/readline/rltypedefs.h:71:29: 错误:‘FILE’在此作用域中尚未声明
71 | typedef int rl_getc_func_t (FILE *);
| ^~~~
/usr/include/readline/rltypedefs.h:1:1: 附注:‘FILE’ is defined in header ‘<cstdio>’; this is probably fixable by adding ‘#include <cstdio>’
+++ |+#include <cstdio>
1 | /* rltypedefs.h -- Type declarations for readline functions. */
/usr/include/readline/rltypedefs.h:71:35: 错误:expected primary-expression before ‘)’ token
71 | typedef int rl_getc_func_t (FILE *);
| ^
In file included from /home/sisabyss/git/db2024/rmdb/src/rmdb.cpp:13:
/usr/include/readline/readline.h:450:21: 错误:‘FILE’在此作用域中尚未声明
450 | extern int rl_getc (FILE *);
| ^~~~
/usr/include/readline/readline.h:39:1: 附注:‘FILE’ is defined in header ‘<cstdio>’; this is probably fixable by adding ‘#include <cstdio>’
38 | # include <readline/tilde.h>
+++ |+#include <cstdio>
39 | #endif
/usr/include/readline/readline.h:450:27: 错误:expected primary-expression before ‘)’ token
450 | extern int rl_getc (FILE *);
| ^
/usr/include/readline/readline.h:591:8: 错误:‘FILE’不是一个类型名
591 | extern FILE *rl_instream;
| ^~~~
/usr/include/readline/readline.h:591:8: 附注:‘FILE’ is defined in header ‘<cstdio>’; this is probably fixable by adding ‘#include <cstdio>’
/usr/include/readline/readline.h:592:8: 错误:‘FILE’不是一个类型名
592 | extern FILE *rl_outstream;
| ^~~~
/usr/include/readline/readline.h:592:8: 附注:‘FILE’ is defined in header ‘<cstdio>’; this is probably fixable by adding ‘#include <cstdio>’
/usr/include/readline/readline.h:623:8: 错误:‘rl_getc_func_t’ does not name a type; did you mean ‘rl_vcpfunc_t’?
623 | extern rl_getc_func_t *rl_getc_function;
| ^~~~~~~~~~~~~~
| rl_vcpfunc_t
/usr/include/readline/readline.h:954:3: 错误:‘FILE’不是一个类型名
954 | FILE *inf;
| ^~~~
/usr/include/readline/readline.h:954:3: 附注:‘FILE’ is defined in header ‘<cstdio>’; this is probably fixable by adding ‘#include <cstdio>’
/usr/include/readline/readline.h:955:3: 错误:‘FILE’不是一个类型名
955 | FILE *outf;
| ^~~~
According to the documentation of GNU/readline, you have to include stdio.h
before include readline, so also can be fixed by include it.
My GNU/GCC version:
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/14.1.1/lto-wrapper
目标:x86_64-pc-linux-gnu
配置为:/build/gcc/src/gcc/configure --enable-languages=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror
线程模型:posix
支持的 LTO 压缩算法:zlib zstd
gcc 版本 14.1.1 20240507 (GCC)