Hi folks

I'm really new to all this, but I feel like this should be an easily solveable issue. If anyone can help me out I'd really (REALLY) appreciate it. I've been struggling with it well over a week!

I'm trying to compile, using VC++ 2005 Express on Windows, the code for a model written in C++, originally for Unix. I've been at it for a while, slowly figuring things out, but now I'm stumped. I'm just not familiar enough with C++ yet to make head or tail of what I feel like is a pretty simple error.

This is a snippet of the build output - the errors shown, all repetitive, apply to the files cstdio and cstring in C:\Program Files\Microsoft Visual Studio 8\VC\include. The errors appear identical for both files as far as I can tell (I get "fatal error C1003: error count exceeds 100; stopping compilation" after only 12 cstring-related errors so I can't tell if there are other files involved).

------ Build started: Project: tarse, Configuration: Release Win32 ------
Compiling...
XMLUtils.cpp
C:\cygwin\usr\include\sys/_types.h(15) : error C2144: syntax error : '__int64' should be preceded by ';'
C:\cygwin\usr\include\sys/_types.h(15) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\cygwin\usr\include\sys/_types.h(34) : error C4980: '__value' : use of this keyword requires /clr:oldSyntax command line option
C:\cygwin\usr\include\sys/_types.h(34) : error C2059: syntax error : '__value'
C:\cygwin\usr\include\sys/reent.h(607) : error C2144: syntax error : 'unsigned __int64' should be preceded by ';'
C:\cygwin\usr\include\sys/reent.h(607) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\cygwin\usr\include\stdlib.h(62) : warning C4392: 'int abs(void)' : incorrect number of arguments for intrinsic function, expected '1' arguments
C:\cygwin\usr\include\stdlib.h(63) : error C2733: second C linkage of overloaded function 'atexit' not allowed
C:\cygwin\usr\include\stdlib.h(63) : see declaration of 'atexit'
C:\cygwin\usr\include\stdlib.h(85) : warning C4392: 'long labs(void)' : incorrect number of arguments for intrinsic function, expected '1' arguments
C:\Program Files\Microsoft Visual Studio 8\VC\include\cstdio(25) : error C2039: 'fpos_t' : is not a member of '`global namespace''
C:\Program Files\Microsoft Visual Studio 8\VC\include\cstdio(25) : error C2873: 'fpos_t' : symbol cannot be used in a using-declaration
C:\Program Files\Microsoft Visual Studio 8\VC\include\cstdio(25) : error C2039: 'FILE' : is not a member of '`global namespace''
C:\Program Files\Microsoft Visual Studio 8\VC\include\cstdio(25) : error C2873: 'FILE' : symbol cannot be used in a using-declaration
C:\Program Files\Microsoft Visual Studio 8\VC\include\cstdio(26) : error C2039: 'clearerr' : is not a member of '`global namespace''
C:\Program Files\Microsoft Visual Studio 8\VC\include\cstdio(26) : error C2873: 'clearerr' : symbol cannot be used in a using-declaration
etc etc etc for 100 errors before stopping and moving on to compile the next .cpp file

Here is the code for XMLUtil.cpp, the source code in question above, though I should add that these errors are repeated exactly for the 4 other .cpp files during the attemped build.

The final error in the report is "Project : warning PRJ0018 : The following environment variables were not found: $(IDB_PATH)"

"_types.h"
Code:
/* ANSI C namespace clean utility typedefs */

/* This file defines various typedefs needed by the system calls that support
   the C library.  Basically, they're just the POSIX versions with an '_'
   prepended.  This file lives in the `sys' directory so targets can provide
   their own if desired (or they can put target dependant conditionals here).
*/

#ifndef	_SYS__TYPES_H
#define _SYS__TYPES_H

#include <sys/lock.h>

typedef long _off_t;
__extension__ typedef long long _off64_t;

#if defined(__INT_MAX__) && __INT_MAX__ == 2147483647
typedef int _ssize_t;
#else
typedef long _ssize_t;
#endif

#define __need_wint_t
#include <stddef.h>

/* Conversion state information.  */
typedef struct
{
  int __count;
  union
  {
    wint_t __wch;
    unsigned char __wchb[4];
  } __value;		/* Value so far.  */
} _mbstate_t;

typedef _LOCK_RECURSIVE_T _flock_t;

/* Iconv descriptor type */
typedef void *_iconv_t;

#endif	/* _SYS__TYPES_H */
and "XMLUtils.cpp" (sorry it's such a beast)
Code:
//;-*-c++-*-

/*! \file  XMLUtils.cpp

  \brief 


  \author Andrew I. James 
  \date 2004-2007 
  \version 1.0.0

  For full copyright information see the file COPYING in the top level directory.

  \license Copyright (C) 2004-2007 Andrew I. James 
       - ajames at waterqualitymodeling dot com -
 
       This program is free software; you can redistribute it and/or modify it
       under the terms of the GNU General Public License as published by the
       Free Software Foundation; either * version 2 of the License, or (at your
       option) any later version.
 
       This program is distributed in the hope that it will be useful, but
       WITHOUT ANY WARRANTY; without even the implied warranty of
       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       General Public License for more details.
 
       You should have received a copy of the GNU General Public License along
       with this program; if not, write to the Free Software Foundation, Inc.,
       675 Mass Ave, Cambridge, MA 02139, USA.
*/
//-*-*- EH -*-*-//

#include "Misc/XMLUtils.hpp"

namespace wqxml {

  using namespace boost::gregorian;
  using namespace boost::posix_time;
  using namespace boost::local_time;

  typedef boost::shared_ptr<ptime>                            ptime_ptr;
  typedef boost::shared_ptr<time_iterator>                    time_iterator_ptr;
  typedef boost::shared_ptr<time_duration>                    time_duration_ptr;


  xmlNodePtr
  get_node( xmlNodePtr start, const std::string& name, bool outermost ) 
  {
    xmlNodePtr curr_node = NULL;
    xmlNodePtr found_node = NULL;
    for ( curr_node = start; curr_node; curr_node = curr_node->next ) {
      if ( curr_node->type == XML_ELEMENT_NODE && xmlStrEqual(curr_node->name, BAD_CAST name.c_str( )) ) {
        found_node = curr_node;
        break;
      }
      found_node = get_node(curr_node->children, name, false);
      if ( found_node != NULL ) break;
    }
    if ( outermost ) XML_THROW_IF_NODE_NOT_FOUND( found_node, name );
    return found_node;
  }

  xmlNodePtr
  get_child_node( xmlNodePtr start, const std::string& name, bool throw_if_nil ) 
  {
    xmlNodePtr curr_node;
    xmlNodePtr found_node = NULL;
    // std::cerr << "Name: " << name << " line: " << start->line << std::endl;
    try {
      for ( curr_node = start->children; curr_node; curr_node = curr_node->next ) {
        if ( curr_node->type == XML_ELEMENT_NODE && xmlStrEqual(curr_node->name, BAD_CAST name.c_str()) ) {
          found_node = curr_node;
          break;
        }
      }
      if ( throw_if_nil ) XML_THROW_IF_NODE_NOT_FOUND( found_node, name );
    }
    catch ( const std::exception& error ) {
      std::cerr << error.what( ) << std::endl;
      assert( 0 );
    }
    return found_node;
  }

  std::string get_node_name( xmlNodePtr np )
  {
    XML_THROW_IF_BAD_NODE( np );
    std::string n_name((char*)np->name);
    std::istringstream iss(n_name);
    std::string the_name;
    iss >> std::skipws >> the_name;
    return the_name;
  }

  bool property_is_equal_to( xmlNodePtr np, const char* prop_name, const char* prop_val )
  {
    XML_THROW_IF_BAD_NODE( np );
    xmlChar* char_name = xmlGetProp( np, BAD_CAST prop_name );
    XML_THROW_IF_ATTRIBUTE_NOT_FOUND( (char*)char_name, prop_name );
    bool prop_is_equal( xmlStrEqual( char_name, BAD_CAST prop_val ) );
    xmlFree( char_name );
    return prop_is_equal;
  }

  template<typename T>
  T get_property( xmlNodePtr np, const char* prop_name, bool throw_if_nil )
  {
    XML_THROW_IF_BAD_NODE( np );
    xmlChar* char_name = xmlGetProp( np, BAD_CAST prop_name );
    if ( throw_if_nil ) XML_THROW_IF_ATTRIBUTE_NOT_FOUND( (char*)char_name, prop_name );
    std::istringstream iss(( char_name != NULL ) ? (char*)char_name : "");
    T the_content;
    if ( char_name != NULL ) iss >> std::skipws >> the_content;
    xmlFree( char_name );
    return the_content;
  }

  // Make sure this doesn't mung up the specialization with <bool>, below.
  template<typename T>
  T get_property( xmlNodePtr np, const char* prop_name, const T& default_val, int dummy )
  {
    XML_THROW_IF_BAD_NODE( np );
    xmlChar* char_name = xmlGetProp( np, BAD_CAST prop_name );
    T the_content(default_val);
    if ( char_name != NULL ) {
      std::istringstream iss( (char*)char_name );
      iss >> std::skipws >> the_content;
    }
    xmlFree( char_name );
    return the_content;
  }

  // Force instantiation
  template std::string get_property<std::string>( xmlNodePtr np, const char* prop_name, 
                                                  bool throw_if_nil );
  template std::string get_property<std::string>( xmlNodePtr np, const char* prop_name, const std::string& def, int dummy );

  template double get_property<double>( xmlNodePtr np, const char* prop_name, bool throw_if_nil );
  template int get_property<int>( xmlNodePtr np, const char* prop_name, bool throw_if_nil );
  template double get_property<double>( xmlNodePtr np, const char* prop_name, const double& default_val, int dummy );


  template<>
  bool get_property<bool>( xmlNodePtr np, const char* prop_name, bool throw_if_nil )
  {
    XML_THROW_IF_BAD_NODE( np );
    xmlChar* char_name = xmlGetProp( np, BAD_CAST prop_name );
    if ( throw_if_nil ) XML_THROW_IF_ATTRIBUTE_NOT_FOUND( (char*)char_name, prop_name );
    std::istringstream iss(( char_name != NULL ) ? (char*)char_name : "");
    bool the_content;
    iss >> std::skipws >> std::boolalpha >> the_content;
    xmlFree( char_name );
    return the_content;
  }

  template<>
  bool get_property<bool>( xmlNodePtr np, const char* prop_name, const bool& default_val, int dummy )
  {
    XML_THROW_IF_BAD_NODE( np );
    xmlChar* char_name = xmlGetProp( np, BAD_CAST prop_name );
    bool the_content(default_val);
    if ( char_name != NULL ) {
      std::istringstream iss( (char*)char_name );
      iss >> std::skipws >> std::boolalpha >> the_content;
    }
    xmlFree( char_name );
    return the_content;
  }

  template<>
  std::vector<int> get_property<std::vector<int> >( xmlNodePtr np, const char* prop_name, bool throw_if_nil )
  {
    XML_THROW_IF_BAD_NODE( np );
    xmlChar* char_name = xmlGetProp( np, BAD_CAST prop_name );
    if ( throw_if_nil ) XML_THROW_IF_ATTRIBUTE_NOT_FOUND( (char*)char_name, prop_name );
    std::istringstream iss(( char_name != NULL ) ? (char*)char_name : "");
    std::vector<int> the_content;
    while ( !iss.eof( ) ) {
      int entry(0);
      iss >> std::skipws >> entry;
      the_content.push_back(entry);
    }
    xmlFree( char_name );
    return the_content;
  }

  template<>
  std::vector<std::string> get_property<std::vector<std::string> >( xmlNodePtr np, const char* prop_name, bool throw_if_nil )
  {
    XML_THROW_IF_BAD_NODE( np );
    xmlChar* char_name = xmlGetProp( np, BAD_CAST prop_name );
    if ( throw_if_nil ) XML_THROW_IF_ATTRIBUTE_NOT_FOUND( (char*)char_name, prop_name );
    std::istringstream iss(( char_name != NULL ) ? (char*)char_name : "");
    std::vector<std::string> the_content;
    while ( !iss.eof( ) ) {
      std::string entry;
      iss >> std::skipws >> entry;
      the_content.push_back(entry);
    }
    xmlFree( char_name );
    // for ( int i = 0; i < the_content.size( ); ++i ) std::cout << the_content[i] << std::endl;
    return the_content;
  }


  char get_action_property( xmlNodePtr np, bool throw_if_nil )
  {
    XML_THROW_IF_BAD_NODE( np );
    xmlChar* char_name = xmlGetProp( np, BAD_CAST "action" );
    if ( throw_if_nil ) XML_THROW_IF_ATTRIBUTE_NOT_FOUND( (char*)char_name, "action" );
    char ret_val = ( xmlStrEqual( char_name, BAD_CAST "mult" ) ) ? '*' : '/';
    xmlFree( char_name );
    return ret_val;
  }

  template<typename T>
  T get_node_content( xmlNodePtr np, bool throw_if_nil )
  {
    XML_THROW_IF_BAD_NODE( np );
    xmlChar* char_name = xmlNodeGetContent( np );
    if ( throw_if_nil ) XML_THROW_IF_CONTENT_NOT_FOUND( (char*)char_name, (char*)np->name );
    std::istringstream iss(( char_name != NULL ) ? (char*)char_name : "");
    T the_content;
    iss >> std::skipws >> the_content;
    xmlFree( char_name );
    return the_content;
  }

  // Have to force instantiation
  template std::string get_node_content<std::string>( xmlNodePtr np, bool throw_if_nil );
  template double get_node_content<double>( xmlNodePtr np, bool throw_if_nil );
  template int get_node_content<int>( xmlNodePtr np, bool throw_if_nil );

  template<>
  bool get_node_content<bool>( xmlNodePtr np, bool throw_if_nil )
  {
    XML_THROW_IF_BAD_NODE( np );
    xmlChar* char_name = xmlNodeGetContent( np );
    if ( throw_if_nil ) XML_THROW_IF_CONTENT_NOT_FOUND( (char*)char_name, (char*)np->name );
    std::istringstream iss(( char_name != NULL ) ? (char*)char_name : "");
    bool the_content;
    iss >> std::skipws >> std::boolalpha >> the_content;
    xmlFree( char_name );
    return the_content;
  }

  template<>
  ptime_ptr get_node_content<ptime_ptr>( xmlNodePtr np, bool throw_if_nil )
  {
    XML_THROW_IF_BAD_NODE( np );
    xmlChar* char_name = xmlNodeGetContent( np );
    if ( throw_if_nil ) XML_THROW_IF_CONTENT_NOT_FOUND( (char*)char_name, (char*)np->name );
    std::stringstream ss(( char_name != NULL ) ? (char*)char_name : "");
    ptime_ptr pt( new ptime(not_a_date_time) );
    ss >> *pt;
    xmlFree( char_name );
    return pt;
  }

  // double get_node_content_as_double( xmlNodePtr np, bool throw_if_nil )
  // {
  //   XML_THROW_IF_BAD_NODE( np );
  //   xmlChar* char_name = xmlNodeGetContent( np );
  //   if ( throw_if_nil ) XML_THROW_IF_CONTENT_NOT_FOUND( (char*)char_name, (char*)np->name );
  //   // std::string 
  //   double val = ( char_name != NULL ) ? atof((char*)char_name) : 0.0 ;
  //   return val;
  // }

  std::string get_node_content_with_whitespace( xmlNodePtr np, bool throw_if_nil )
  {
    XML_THROW_IF_BAD_NODE( np );
    xmlChar* char_name = xmlNodeGetContent( np );
    if ( throw_if_nil ) XML_THROW_IF_CONTENT_NOT_FOUND( (char*)char_name, (char*)np->name );
    std::istringstream iss(( char_name != NULL ) ? (char*)char_name : "");
    xmlFree( char_name );
    return iss.str( );
  }


  std::string xml_xpath_get_string( xmlNodePtr np, const std::string& name, bool throw_if_nil )
  {
    if ( throw_if_nil ) XML_THROW_IF_BAD_NODE( np );
    std::string the_name = (char*) xmlNodeGetContent( np );
    return the_name;
  }

  bool xml_xpath_get_bool( xmlNodePtr np, const std::string& name, bool throw_if_nil )
  {
    if ( throw_if_nil ) XML_THROW_IF_BAD_NODE( np );
    xmlChar* cp = xmlNodeGetContent( np );
    // perhaps not use a string for this...
    std::string the_bool = ( cp != NULL ) ? (char*)cp : "" ;
    xmlFree( cp );
    return ( the_bool == "true" || the_bool == "True" || the_bool == "yes" 
             || the_bool == "Yes" || the_bool == "1" );
  }

  double xml_xpath_get_double( xmlNodePtr np, const std::string& name, bool throw_if_nil )
  {
    if ( throw_if_nil ) XML_THROW_IF_BAD_NODE( np );
    xmlChar* cp = xmlNodeGetContent( np );
    double ret_val = ( cp != NULL ) ? atof((char*)cp) : 0.0; 
    xmlFree( cp );
    return ret_val;
  }

};
I've had no dice on codeguru so here's hoping you guys & gals can give me some hope...