• 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: undefined __throw
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: undefined __throw
      • From: Chris Espinosa <email@hidden>
References: 
 >undefined __throw (From: Jeremy Sagan <email@hidden>)
 >Re: undefined __throw (From: Jeremy Sagan <email@hidden>)
 >Re: undefined __throw (From: Jon Guyer <email@hidden>)
 >Re: undefined __throw (From: Jeremy Sagan <email@hidden>)

  • Prev by Date: Re: undefined __throw
  • Next by Date: Re: How to step through unit test bundle execution in Xcode 2.1?
  • Previous by thread: Re: undefined __throw
  • Next by thread: Re: undefined __throw
  • Index(es):
    • Date
    • Thread