Compilation errors with XmlReader

With the following code in my project:

00: System::Drawing::Point ImageImporter::_loadOffset(System::String ^path)
01: {
02: Point pt;
03
: try
05
: {
06
: XmlReaderSettings ^ settings = gcnew XmlReaderSettings();
07
: settings->IgnoreWhitespace = true;
08
:
09: System::Xml::XmlReader ^ reader =
10
: System::Xml::XmlReader::Create(path, settings);
11
:
12: while (!reader->EOF)
13
: {
14
: if (reader->IsStartElement("x"))
15
: {
16
: pt.X = reader->ReadElementContentAsInt();
17
: }
18
: if (reader->IsStartElement("y"))
19
: {
20
: pt.Y = reader->ReadElementContentAsInt();
21
: }
22
: reader->Read();
23
: }
24
: }
25
: catch (System::Exception ^e)
26
: {
27
: Debug::WriteLine(e->Message);
28
: return Point(0, 0);
29
: }
30
:
31: return pt;
32
: }

I get the following compiler errors:

line 12: error C2039: 'reader' : is not a member of 'System::Xml::XmlReader'
line 13: error C2059: syntax error : '('
line 14: error C2143: syntax error : missing ';' before '{'
line 14: error C2232: '->System::Xml::XmlReader::IsStartElement' : left operand has '' type, use '.'


Any suggestions


Answer this question

Compilation errors with XmlReader

  • alex121

    Solved my own problem. Somewhere along the include chain, <stdio.h> was included, which has a #define EOF (-1). A simple #undef and everything was shiny.

  • Compilation errors with XmlReader