This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project. See the Cygwin home page for more information.
Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: set_new_handler


Sven.Wastlund@epkadm.epk.ericsson.se (Sven Wastlund) writes:
> I am porting a program from UNIX to NT which uses the function set_new_handle
> r and I linked it with libgcc.a but I still got the error:
> 
> undefined reference to set_new_handler

Without any code, it's impossible to figure out why you're getting this.
Post a short test case and someone will look into it. Short answer is
that it's there and it works.

Are you including <new> in your code to pick up the right prototype?

> Is there any other library I can use?

no.

here's a quick example (haven't tested it, so beware for syntax errors
and so on):

  #include <new>
  #include <iostream>

  void my_handler () {
    cerr << "no more memory" << endl;
    abort ();
  }

  int main( void ) {
   set_new_handler (&my_handler);
   int *foo = new int [100000000];
  }

$ c++ -o new-handler new-handler.cc
$ ./new-handler

Regards,
Mumit


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com