I am just getting back into programming so am a bit rusty on some things, but this just seems bizarre. I am trying to build a C++ Command Line app, as that seems the closes to a plain C++ program without all the user interface stuff. I am trying to include some code from a book C++ Algorthyms for DSP. In it there is the following function: /////////////////////////////////////////////////////////////////////////// // // convType( const type_info& ti ) // Converts C++ run-time type information to C DSP_FILE // // Returns: // Enumerated C DSP_FILE type (see DSPFILETYPE above) // /////////////////////////////////////////////////////////////////////////// // error: ISO C++ forbids declaration of 'type_info' with no type inline DSPFILETYPE convType( const type_info &ti ) { // Convert type to C DSP_FILE type if( ti == typeid( unsigned char ) ) return UNSIGNED_CHAR; else if( ti == typeid( signed char ) ) return SIGNED_CHAR; else if( ti == typeid( unsigned short ) ) return UNSIGNED_SHORT; else if( ti == typeid( signed short ) ) return SIGNED_SHORT; else if( ti == typeid( unsigned long ) ) return UNSIGNED_LONG; else if( ti == typeid( signed long ) ) return SIGNED_LONG; else if( ti == typeid( float ) ) return FLOAT; else if( ti == typeid( double ) ) return DOUBLE;
// Additional types for C++ else if( ti == typeid( unsigned int ) ) return UNSIGNED_INT; else if( ti == typeid( signed int ) ) return SIGNED_INT; else if( ti == typeid( Complex ) ) return COMPLEX;
return UNKNOWN_TYPE; }
This causes the compiler to complain:"error: ISO C++ forbids declaration of 'type_info' with no type." on the line DSPFILETYPE convType( This does not appear to be a declaration to me. In addition, in one of my C++ books I see this exact usage. I am at a loss to figure out why. In the original code, which was I admit written to compile under Visuall C++, there was an include for #include <typeinfo.h> which caused the compiler to barf, so I removed it. Is there an equivalent that I need to include ?
I also am getting errors on the declaration fstream m_fs. it says "error: 'fstream' does not declare a type. I see this exact type of declaration in my C++ book, and I cannot see anything in the headers that contradict it.
I am baffled by these errors. |