To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 2154
2153  |  2155
Subject: 
legOS C++ questions
Newsgroups: 
lugnet.robotics
Date: 
Sat, 2 Jan 1999 20:22:34 GMT
Viewed: 
1348 times
  
I'm having some more success and of course more problems.

I whipped up a C++ version of one of the demo programs.
I successfully compiled and linked it after adding a
a few routines from the libgcc2.c see below.

As long as I create my class objects on the stack and
don't use any task management routines the C++ constructors
and destructors get called automatically.  However, when
I add the execi calls the destructors no longer get invoked.
I'm assuming that is because of the way tm.c manipulates
the return function.  It appears to stuff the address
of the exit routine on the stack.  I would guess it is
replacing the destructor call.  Is there a way around this?

If these questions are not appropriate for this group
please let me know and I will stop asking them.

--  routines from libgcc2.c --
extern "C" {

void __builtin_delete(void *ptr)
{
    if ( ptr )
free(ptr);
}

void *top_elt[2];
void **_dynamic_handler_chain = top_elt;

void *** __get_dynamic_handler_chain()
{
    return &_dynamic_handler_chain;
}

}



Message has 1 Reply:
  Re: legOS C++ questions
 
(...) Destructors for stack-based objects get run as soon as the enclosing scope exits. If you call exit, the compiler doesn't know it needs to destroy them first. If you dynamically allocate objects, you have to destroy them yourself for the (...) (26 years ago, 3-Jan-99, to lugnet.robotics)

2 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    
Active threads in Robotics

 
Verified and Trusted Team of Hackers
11 hours ago
Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR