Re: undefined __throw
Re: undefined __throw
- Subject: Re: undefined __throw
- From: Jeremy Sagan <email@hidden>
- Date: Thu, 07 Jul 2005 21:14:40 -0400
Chris,
Thank you. That works fine but why, when I try to use the same source code as a carbon or carbon bundle application, is keyword 'try' illegal and 'iostream' is not found?
I need use try, catch and throw under a carbon bundle.
Jeremy
On Jul 7, 2005, at 8:32 PM, Chris Espinosa wrote:
On Jul 7, 2005, at 4:18 PM, Jeremy Sagan wrote:
Obviously I am a newbie with Xcode and C++ exceptions but I can't understand why this other simple program I found online does not compile.
After having linking problems with try, catch and throw, I tried creating a new carbon project but when I try to compile it, xcode cannot find iostream.h even though "iostream.h" will open-quickly without problem. I tried changing my header paths but that does not seem to help.
Please help. Here is the file c++ test file I found....
/**************************************************************************
*
* Language: C++
* Purpose: Program to demonstrate the 'try', 'catch' and 'throw' statements.
* Author: M J Leslie
* Date: 21-Mar-98
Much has changed in the C++ world in the last 7 years. Here is a more useful source file that compiles and runs when pasted into "main.cp" in a new Xcode "Command Line C++ Tool" project:
/**************************************************************************
*
* Language: C++
* Purpose: Program to demonstrate the 'try', 'catch' and 'throw' statements.
* Author: M J Leslie
* Date: 21-Mar-98
*
* Compile: The following command was used to compile.
*
* g++ -fhandle-exceptions throw.cc -o throw
*
**************************************************************************/
#include <iostream> // For cout.
void ErrorFunc(int Error);
int main (int argc, char * const argv[])
{
ErrorFunc(0);
ErrorFunc(1);
return 0;
}
void ErrorFunc(int Error)
{
try
{
std::cout << "Error code is " << Error << std::endl;
if (Error > 0 )
{
throw(Error); // This statement causes control to jump
// to the 'catch' statement
}
std::cout << "No Error occoured" << std::endl;
}
int n)
{
std::cout << "Error number is " << n << std::endl;;
}
}
Note the important differences:
• the prototype for main is standardized
• there's a return from main
• cout and endl are invoked in the std:: namespace
• <iostream> is included instead of <iostream.h>
Chris
_______________________________________________
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