Open jsrdzhk opened 2 years ago
What version of yaml-cpp?
On Thu, Sep 22, 2022 at 9:29 PM Rodney Cheung @.***> wrote:
I build shared library with cmake by:
cmake -B build_v140_x64 -G "Visual Studio 14 2015" -A x64 -DYAML_BUILD_SHARED_LIBS=on -DYAML_CPP_BUILD_TESTS=off cmake --build build_v140_x64 --config Release
The demo yaml file is:
diagnoser: trade-gw: enable: falsetest1: 10
I link the yaml-cpp.dll by:
find_library( YAML_CPP_LIB NAMES yaml-cpp.lib PATHS ${THIRD_PARTY_LIB_PATH} NO_DEFAULT_PATH) target_link_libraries(test_yaml_cpp PRIVATE ${YAML_CPP_LIB})
test code:
int main() { try { fs::path yamlPath = "C:\my_proj\cpp_test\src\test_yaml_cpp\checker.yaml"; if (!fs::exists(yamlPath)) { return -1; } YAML::Node root = YAML::LoadFile(yamlPath.string()); std::cout << "root size:" << root.size() << std::endl; auto diag_node = root["diagnoser"]; if (diag_node) { std::cout << diag_node["trade-gw"]["enable"].as
() << std::endl; } std::cout << root["test1"].as () << std::endl; } catch (const YAML::ParserException& e) { std::cout << "ParserException parse config file failed:" << e.msg << std::endl; return -1; } catch (const YAML::BadFile& e) { std::cout << "BadFile parse config file failed:" << e.msg << std::endl; return -2; } catch (const std::exception& e) { std::cout << "parse config file failed:" << e.what() << std::endl; return -3; } return 0; } output:
parse config file failed:bad allocation
— Reply to this email directly, view it on GitHub https://github.com/jbeder/yaml-cpp/issues/1134, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAICUBV5IVHEJOMXXQEYJTLV7UIYFANCNFSM6AAAAAAQTSZ2TY . You are receiving this because you are subscribed to this thread.Message ID: @.***>
yaml-cpp-0.7.0
Also this is super surprising and you might do better by asking on Stack Overflow.
On Thu, Sep 22, 2022 at 9:36 PM Jesse Beder @.***> wrote:
What version of yaml-cpp?
On Thu, Sep 22, 2022 at 9:29 PM Rodney Cheung @.***> wrote:
I build shared library with cmake by:
cmake -B build_v140_x64 -G "Visual Studio 14 2015" -A x64 -DYAML_BUILD_SHARED_LIBS=on -DYAML_CPP_BUILD_TESTS=off cmake --build build_v140_x64 --config Release
The demo yaml file is:
diagnoser: trade-gw: enable: falsetest1: 10
I link the yaml-cpp.dll by:
find_library( YAML_CPP_LIB NAMES yaml-cpp.lib PATHS ${THIRD_PARTY_LIB_PATH} NO_DEFAULT_PATH) target_link_libraries(test_yaml_cpp PRIVATE ${YAML_CPP_LIB})
test code:
int main() { try { fs::path yamlPath = "C:\my_proj\cpp_test\src\test_yaml_cpp\checker.yaml"; if (!fs::exists(yamlPath)) { return -1; } YAML::Node root = YAML::LoadFile(yamlPath.string()); std::cout << "root size:" << root.size() << std::endl; auto diag_node = root["diagnoser"]; if (diag_node) { std::cout << diag_node["trade-gw"]["enable"].as
() << std::endl; } std::cout << root["test1"].as () << std::endl; } catch (const YAML::ParserException& e) { std::cout << "ParserException parse config file failed:" << e.msg << std::endl; return -1; } catch (const YAML::BadFile& e) { std::cout << "BadFile parse config file failed:" << e.msg << std::endl; return -2; } catch (const std::exception& e) { std::cout << "parse config file failed:" << e.what() << std::endl; return -3; } return 0; } output:
parse config file failed:bad allocation
— Reply to this email directly, view it on GitHub https://github.com/jbeder/yaml-cpp/issues/1134, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAICUBV5IVHEJOMXXQEYJTLV7UIYFANCNFSM6AAAAAAQTSZ2TY . You are receiving this because you are subscribed to this thread.Message ID: @.***>
but these code works well on linux
Right, but the problem might be in your windows setup and not in yaml-cpp.
Also, try at HEAD instead of 0.7.0 and see if that helps.
On Thu, Sep 22, 2022 at 9:42 PM Rodney Cheung @.***> wrote:
but these code works well on linux
— Reply to this email directly, view it on GitHub https://github.com/jbeder/yaml-cpp/issues/1134#issuecomment-1255744460, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAICUBXSKBDGHA65UGRDHITV7UKK7ANCNFSM6AAAAAAQTSZ2TY . You are receiving this because you commented.Message ID: @.***>
I build shared library with cmake by:
The demo yaml file is:
I link the yaml-cpp.dll by:
test code:
output: