Re: Help with type_id and fstream
Re: Help with type_id and fstream
- Subject: Re: Help with type_id and fstream
- From: Rua Haszard Morris <email@hidden>
- Date: Mon, 3 Sep 2007 13:40:00 +1200
Sounds like the file is not being compiled as C++ (is it .cpp?) and/
or some features of C++ need to be turned on.
There is an option for C++ run-time type info, which (I imagine)
you'll need ON for the type_info to work, though I believe it's on by
default. The option is GCC_ENABLE_CPP_RTTI, look in the project &
target settings under GNU C++ Compiler 4.0>Language. I'm guessing
that including typeinfo.h is a good idea too..
Also check it's being compiled as C++ by doing a get info on the file
(in the Xcode project), General tab, file type should be
sourcecode.cpp.cpp.
have fun...
On 3/09/2007, at 1:18 PM, Dale Satterfield wrote:
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.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40adinstruments.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden