Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toml::parse: Error opening file "...": iostream error #212

Open
FuexFollets opened this issue Jan 23, 2023 · 1 comment
Open

toml::parse: Error opening file "...": iostream error #212

FuexFollets opened this issue Jan 23, 2023 · 1 comment

Comments

@FuexFollets
Copy link

Currently, I am attempting to use toml::parse on a file named basic_toml.toml. When I do so, I get this error in the title. I've checked a few times and the error persists.

I am using the library by including it in the include paths.

Here is some other info:

  • Compiler: g++
  • Options: -g -Wall -pedantic -std=c++20

Here is the code:

// main.cpp

#include <fstream>
#include <iostream>
#include <string>
#include <toml.hpp>

int main() {
    std::string toml_file_path {"./basic_toml.toml"};
    const toml::value parsed_toml = toml::parse(toml_file_path);

    std::cout << "Value: " << toml::find<int>(parsed_toml, "value") << '\n';
}

basic_toml.toml

value = 34
@ToruNiina
Copy link
Owner

Sorry, but I could not reproduce it. On my laptop (g++11, the same option), the same code & file works.

If std::ifstream ifs(fname, std::ios::binary) fails (!ifs.good()), it throws an error with the message you reported. I have no idea what is happening inside ifstream and your filesystem, but you can try to open a file with fopen and pass a FILE* to toml::parse(FILE*, std::string file_name) in order to use another way to read a file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants