Question

I am running the example found here to try out using YAML in C++. I copied the code verbatim into test.cpp in a new project folder. I compiled YAML into a static library and am linking it to my project. I'm running Ubuntu 11.10. I use the following command to compile:

    g++ -Wall -I. -g test.cpp -lyaml-cpp -L.

I get the following error statement:

    terminate called after throwing an instance of 'YAML::ParserException'
       what(): yaml-cpp: error at line 4, column 2: illegal block entry
    Aborted

What is the meaning of this exception? And what could be wrong? I couldn't find a clear documentation for what each of the exceptions could mean, so even a link to this information would be helpful. I am probably out of my depth, as I am new to YAML, using libraries, and linux for that matter. Thanks in advance for your help.

Edit: The error occurs before "parser.GetNextDocument(doc)". Also, I ran a simpler example from the website that stores a single scalar, and that worked fine. Is the exception about my input file, or my code?

Was it helpful?

Solution

The error indicates that there's a problem with the input file (monsters.yaml). Make sure you copied it exactly. It claims there's an error at line 4, column 2, so you can look at that spot first (but yaml-cpp isn't great with location of errors, so that may not be the right spot to look at).

Things to make sure about:

  • spaces, not tabs
  • the proper number of spaces for indentation
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top