PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.cplus > Static constructors: a complex problem
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Static constructors: a complex problem

Réponse
 
LinkBack Outils de la discussion
Vieux 03/06/2008, 18h45   #1
Pegasus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Static constructors: a complex problem

Let's suppose that, under a particular platform,
the compiler doesn't initialize correctly the
global constructors and destructors at
startup.

The compiler is psp-gcc.

I have written two routines,

__do_constructor_initialization_aux

and

__do_destructor_initialization_aux

that, if recalled explictly by the code of
the program, start the routines generated
by the compiler and initialize the global
constructors (o deinitialize the constructors
when the program finish).

Unfortunately, each of this routine can access
only to the .ctor or .dtor section of the module
in which it is compiled, not to the .ctor or .dtor
section of different modules.

So, if you are compiling a project in C++ that
contains n files .o, **in each of these** a routine
__do_constructor_initialization_aux and
a routine __do_destructor_initialization_aux
must be present.

If the project has n object .o, there will be n
__do_constructor_initialization_aux routines and
n __do_destructor_initialization_aux routines.

N isn't a known number, because it depends from
the o. files that the programmer chooses to
create.

The trouble is the following: who start these
routines at startup ?

It is needed a special symbol in psp-gcc or in
psp-ld that makes that, at startup, before that
main () is executed, the cpu executes all
initialitation routines present in each module
that has been linked.

Any idea ?



  Réponse avec citation
Vieux 03/06/2008, 18h54   #2
Victor Bazarov
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Static constructors: a complex problem

Pegasus wrote:
> Let's suppose that, under a particular platform,
> the compiler doesn't initialize correctly the
> global constructors and destructors at
> startup.


Not sure what you mean by "initialize correctly the global
constructors". Constructors are functions, what's there to initialise,
correctly or otherwise?

> The compiler is psp-gcc.
> [... something about routines to be called at startup and exit ...]
>
> The trouble is the following: who start these
> routines at startup ?


<shrug> There is *no mechanism* in the /Standard C++/ to call anything
at startup *except* by means of the constructor of a global object. If
those don't work, you're in the implementation-specific territory and
you need to post your question to the newsgroup/forum dedicated to the
compiler of your choice.

> It is needed a special symbol in psp-gcc or in
> psp-ld that makes that, at startup, before that
> main () is executed, the cpu executes all
> initialitation routines present in each module
> that has been linked.
>
> Any idea ?


Well, not really. It's off-topic.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
  Réponse avec citation
Vieux 04/06/2008, 00h31   #3
jason.cipriani@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Static constructors: a complex problem

On Jun 3, 1:45 pm, "Pegasus" <non...@nowhere.com> wrote:
> Let's suppose that, under a particular platform,
> the compiler doesn't initialize correctly the
> global constructors and destructors at
> startup.
>
> The compiler is psp-gcc.
>
> I have written two routines,
>
> __do_constructor_initialization_aux
>
> and
>
> __do_destructor_initialization_aux


In general, if you are doing something really weird like this, then
you are also doing something really wrong.

A quick Google search for "psp-gcc
__do_constructor_initialization_aux" yields no results. A slightly
less quick Google search for psp-gcc and problems related to broken
static initialization yielded no relevant results. Are you sure that
this is a psp-gcc related problem? Buggy static initialization with
the psp-gcc compiler seems to me like it would be a more widely-known
problem with more information. Since you seem to be one of a handful,
if not the only person, suffering from whatever problem this is, you
should double-check to make sure you aren't doing something weird
somewhere else.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h00.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08614 seconds with 11 queries