code
Код: Выделить всё
#include
#include
int main() {
YAML::Node config = YAML::Load("test.yaml");
std::vector validKeys = {"key1", "key2", "key3"}; // List of valid keys
for (YAML::const_iterator it = config.begin(); it != config.end(); ++it) {
std::string key = it->first.as();
// Check if the key is valid
if (std::find(validKeys.begin(), validKeys.end(), key) == validKeys.end()) {
std::cerr
Когда я пытался скомпилировать его таким образом < /p>
g++ -I/opt/homebrew/Cellar/yaml-cpp/0.8.0/include -L/opt/homebrew/Cellar/yaml-cpp/0.8.0/lib -lyaml-cpp -o read read.cppЯ получаю сообщения об ошибках:
Код: Выделить всё
In file included from read.cpp:2:
In file included from /opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/yaml.h:10:
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/parser.h:31:27: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
Parser(const Parser&) = delete;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/parser.h:32:16: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
Parser(Parser&&) = delete;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/parser.h:32:22: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
Parser(Parser&&) = delete;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/parser.h:33:38: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
Parser& operator=(const Parser&) = delete;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/parser.h:34:27: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
Parser& operator=(Parser&&) = delete;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/parser.h:34:33: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
Parser& operator=(Parser&&) = delete;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/parser.h:45:3: warning: explicit conversion functions are a C++11 extension [-Wc++11-extensions]
explicit operator bool() const;
^~~~~~~~
In file included from read.cpp:2:
In file included from /opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/yaml.h:11:
In file included from /opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/emitter.h:18:
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/binary.h:23:17: error: expected member name or ';' after declaration specifiers
: m_data{}, m_unownedData(data_), m_unownedSize(size_) {}
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/binary.h:26:17: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
Binary(Binary &&) = default;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/binary.h:26:23: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
Binary(Binary &&) = default;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/binary.h:27:39: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
Binary &operator=(const Binary &) = default;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/binary.h:28:28: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
Binary &operator=(Binary &&) = default;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/binary.h:28:34: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
Binary &operator=(Binary &&) = default;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/binary.h:23:15: error: expected '('
: m_data{}, m_unownedData(data_), m_unownedSize(size_) {}
^
In file included from read.cpp:2:
In file included from /opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/yaml.h:11:
In file included from /opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/emitter.h:23:
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/ostream_wrapper.h:20:45: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
ostream_wrapper(const ostream_wrapper&) = delete;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/ostream_wrapper.h:21:34: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
ostream_wrapper(ostream_wrapper&&) = delete;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/ostream_wrapper.h:21:40: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
ostream_wrapper(ostream_wrapper&&) = delete;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/ostream_wrapper.h:22:56: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
ostream_wrapper& operator=(const ostream_wrapper&) = delete;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/ostream_wrapper.h:23:45: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
ostream_wrapper& operator=(ostream_wrapper&&) = delete;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/ostream_wrapper.h:23:51: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
ostream_wrapper& operator=(ostream_wrapper&&) = delete;
^
In file included from read.cpp:2:
In file included from /opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/yaml.h:11:
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/emitter.h:37:29: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
Emitter(const Emitter&) = delete;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/emitter.h:38:40: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
Emitter& operator=(const Emitter&) = delete;
^
In file included from read.cpp:2:
In file included from /opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/yaml.h:13:
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/stlemitter.h:19:14: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (const auto& v : seq)
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/stlemitter.h:19:22: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (const auto& v : seq)
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/stlemitter.h:43:14: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (const auto& v : m)
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/stlemitter.h:43:22: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (const auto& v : m)
^
In file included from read.cpp:2:
In file included from /opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/yaml.h:14:
In file included from /opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:12:
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/traits.h:87:16: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using type = T;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/traits.h:98:16: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using type = T;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/traits.h:111:10: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
static auto test(int)
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/traits.h:111:10: error: 'auto' not allowed in function return type
static auto test(int)
^~~~
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/traits.h:111:24: error: expected ';' at end of declaration list
static auto test(int)
^
;
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/traits.h:115:10: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
static auto test(...) -> std::false_type;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/traits.h:115:10: error: 'auto' not allowed in function return type
static auto test(...) -> std::false_type;
^~~~
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/traits.h:115:24: error: expected ';' at end of declaration list
static auto test(...) -> std::false_type;
^
;
In file included from read.cpp:2:
In file included from /opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/yaml.h:14:
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:93:47: error: a space is required between consecutive right angle brackets (use '> >')
const T&, typename disable_if::type* = 0) {
^~
> >
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:111:50: error: a space is required between consecutive right angle brackets (use '> >')
const T& key, typename enable_if::type* = 0) {
^~
> >
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:119:47: error: a space is required between consecutive right angle brackets (use '> >')
const T&, typename disable_if::type* = nullptr) {
^~
> >
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:137:50: error: a space is required between consecutive right angle brackets (use '> >')
const T& key, typename enable_if::type* = nullptr) {
^~
> >
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:157:3: error: exception specification of overriding function is more lax than base version
~Exception() YAML_CPP_NOEXCEPT override;
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/stdexcept:114:5: note: overridden virtual function is here
~runtime_error() _NOEXCEPT override;
^
In file included from read.cpp:2:
In file included from /opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/yaml.h:14:
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:157:15: error: expected ';' at end of declaration list
~Exception() YAML_CPP_NOEXCEPT override;
^
;
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:159:33: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
Exception(const Exception&) = default;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:182:45: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
ParserException(const ParserException&) = default;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:183:21: error: expected ';' at end of declaration list
~ParserException() YAML_CPP_NOEXCEPT override;
^
;
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:190:61: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
RepresentationException(const RepresentationException&) = default;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:191:29: error: expected ';' at end of declaration list
~RepresentationException() YAML_CPP_NOEXCEPT override;
^
;
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:199:41: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
InvalidScalar(const InvalidScalar&) = default;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:200:19: error: expected ';' at end of declaration list
~InvalidScalar() YAML_CPP_NOEXCEPT override;
^
;
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:209:37: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
KeyNotFound(const KeyNotFound&) = default;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:210:17: error: expected ';' at end of declaration list
~KeyNotFound() YAML_CPP_NOEXCEPT override;
^
;
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:218:22: error: expected ';' at end of declaration list
~TypedKeyNotFound() YAML_CPP_NOEXCEPT override = default;
^
;
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:234:37: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
InvalidNode(const InvalidNode&) = default;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:235:17: error: expected ';' at end of declaration list
~InvalidNode() YAML_CPP_NOEXCEPT override;
^
;
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:242:41: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
BadConversion(const BadConversion&) = default;
^
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:243:19: error: expected ';' at end of declaration list
~BadConversion() YAML_CPP_NOEXCEPT override;
^
;
/opt/homebrew/Cellar/yaml-cpp/0.8.0/include/yaml-cpp/exceptions.h:256:43: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
BadDereference(const BadDereference&) = default;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
36 warnings and 20 errors generated.
< /code>
и почему я пытаюсь скомпилировать его таким образом < /p>
g++ -I/opt/homebrew/Cellar/libyaml/0.2.5/include -L/opt/homebrew/Cellar/libyaml/0.2.5/lib -lyaml-cpp -o read read.cppЯ получаю это сообщение об ошибке
Код: Выделить всё
read.cpp:2:10: fatal error: 'yaml-cpp/yaml.h' file not found
#include
^~~~~~~~~~~~~~~~~
1 error generated.
Опять же, я очень новичок в C ++, так что прости мое невежество. < /p>
Подробнее здесь: https://stackoverflow.com/questions/794 ... g-yaml-cpp
Мобильная версия