utility(21) : error C2059: syntax error : 'end of file'

I have worked in C and C++ for a while, but have always made an effort to avoid class templates and especailly the STL. Well now I have found some code that represents a client that would be really useful to me but it uses STL extensively.

Anyway I compiled the client and it compiled fine. I then noticed that the client contained two seperate buffers (each is a list<string>) that could be used at the same time, but was only using one mutex to control access to both. Access to wait and release the mutex is controlled through two class methods and the mutex itself is private. Other class functions dealing with the two buffers use a const std::string& to decide which buffer to work on so I changed the class def (.h) as well as the implementation (.cpp) for the two mutex functions by adding an additional const std::string& to the beginning of the arguments of each (of course I also created the second private mutex). Other changes in the client needed to be made where other project members made use of the mutex functions, but only four changes were required (two pair), once where a buffer is read from (and item is removed) the other where the second buffer is written to.

Now I get the error listed in the subject.

Line 21 appears to be dealing with a constructor for the pair struct. I have checked the modified date of <utility> but it checks out with a date from 1998. I am at a complete loss. Any thoughts about what this is or how I go about troubleshooting it



Answer this question

utility(21) : error C2059: syntax error : 'end of file'

  • Fahad349

    I still can't find the problem but I went back to the original source for the client, made the same changes, compiling after each addition, and now it compiles fine with all of my changes in place. Thanks anyway!
  • Constantijn Enders

    quiklearner wrote:

    I have worked in C and C++ for a while, but have always made an effort to avoid class templates and especailly the STL. Well now I have found some code that represents a client that would be really useful to me but it uses STL extensively.

    Don't stay away from the STL! It's a brilliant library, and as you use it, I assure you you'll learn to love it

    quiklearner wrote:

    Anyway I compiled the client and it compiled fine. I then noticed that the client contained two seperate buffers (each is a list<string>) that could be used at the same time, but was only using one mutex to control access to both. Access to wait and release the mutex is controlled through two class methods and the mutex itself is private. Other class functions dealing with the two buffers use a const std::string& to decide which buffer to work on so I changed the class def (.h) as well as the implementation (.cpp) for the two mutex functions by adding an additional const std::string& to the beginning of the arguments of each (of course I also created the second private mutex). Other changes in the client needed to be made where other project members made use of the mutex functions, but only four changes were required (two pair), once where a buffer is read from (and item is removed) the other where the second buffer is written to.

    That sounds like a multi-part problem. If you want to shed some more light on the potential race conditions and thread compromisation, you should provide a tad more information about the code layout, as well as the general flow throughout the application. A quick digression, this being thread related: I'm working on a library you may (or may not) find handy, which can be found at http://www.codeproject.com/useritems/threadsynch.asp. If nothing else; it does describe alternative ways of dealing with interlocked access to shared resources such as your lists.

    quiklearner wrote:

    Now I get the error listed in the subject.

    Line 21 appears to be dealing with a constructor for the pair struct. I have checked the modified date of <utility> but it checks out with a date from 1998. I am at a complete loss. Any thoughts about what this is or how I go about troubleshooting it

    Which version of VC are you using The file dating back to 1998 suggests VC6, which in that case may very well be your culprit. A lot has changed since then (especially considering that the STL wasn't fully specified when VC6 was written / released), so it's entirely possible that the issue you are witnessing is caused by an actual library or compiler bug.

    In either case, can you paste the lines referenced in your error message, and perhaps attempt to reproduce it with as low a source size as possible



  • Mystagogue

    Did you look at the documentation of error code C2059

  • Chrono20944

    The docs I have read indicate it is usually due to parens not being closed.. I have reviewed and have not found anything suspicious. Also the <utility> is not included locally but by including <vector> which includes <xutility> which includes <utility> (my theory on how it got included). <vector> is the second include at the top of the .h and should be processed way before it sees any changes I have made... (or maybe i am unclear on how this works)
  • utility(21) : error C2059: syntax error : 'end of file'