Re: RFC: glocal - automatically freeing memory when it goes out of scope

> gcc's constructor and destructor attributes as I understand them are
> principally used in connection with the loading and unloading of
> shared libraries at program start-up and close down, although I
> imagine they have other uses.  If you say those may require OS
> support I
> will believe you (certainly shared libraries do), and in terms of
> ubiquity I do not dispute that their use and/or availability for C is
> more widespread than, say, cleanup attributes.

I might have been a bit sloppy with my words, but the following C++ code, in a shared library:

MyClass my_object;

Needs to have the MyClass constructor for the static object my_object run before the main() function in your application. This is identical to attribute constructor (in fact, implementation wise thats how this works in C++).

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]