• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: Help with type_id and fstream
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Help with type_id and fstream


  • Subject: RE: Help with type_id and fstream
  • From: "Luca Ciciriello" <email@hidden>
  • Date: Mon, 03 Sep 2007 17:34:37 +0100

As a test I've wrote the following code embedding your function.

#include <typeinfo>
#include <iostream>
using namespace std;

enum DSPFILETYPE
{
   UNSIGNED_CHAR,
   SIGNED_CHAR,
   UNSIGNED_SHORT,
   SIGNED_SHORT,
   UNSIGNED_LONG,
   SIGNED_LONG,
   FLOAT,
   DOUBLE,
   UNSIGNED_INT,
   SIGNED_INT,
   COMPLEX,
   UNKNOWN_TYPE
};

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; }

int main(int argc, char *argv[])
{
   DSPFILETYPE type = convType(typeid(int));
	cout << type << endl;
   return 0;
}

I've created a C++ command utility project and all works fine (build and run).
Please check if is checked the flag "Enable C++ runtime type".


Let me know.

Luca.


From: Dale Satterfield <email@hidden>
To: email@hidden
Subject: Help with type_id and fstream
Date: Sun, 2 Sep 2007 18:18:49 -0700

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:
This email sent to email@hidden

_________________________________________________________________ The next generation of Hotmail is here! http://www.newhotmail.co.uk

_______________________________________________
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


References: 
 >Help with type_id and fstream (From: Dale Satterfield <email@hidden>)

  • Prev by Date: Re: Adding Help
  • Next by Date: RE: Help with type_id and fstream
  • Previous by thread: Re: Help with type_id and fstream
  • Next by thread: RE: Help with type_id and fstream
  • Index(es):
    • Date
    • Thread