[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::c_plus_plus

Title:C++
Notice:Read 1.* and use keywords (e.g. SHOW KEY/FULL KIT_CXX_VAX_VMS)
Moderator:DECCXX::AMARTIN
Created:Fri Nov 06 1987
Last Modified:Thu Jun 05 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3604
Total number of notes:18242

3553.0. "Explanation needed for __init variable name" by CSC64::BLAYLOCK (If at first you doubt,doubt again.) Wed Apr 23 1997 22:58

This may be purely related to the use of an old compiler (V5.1)
but... (Digital UNIX V4.0a)

My customer has noticed that for the following .h file, if
the include lines are reversed, the name of the initializer
changes, for example (from odump -Ds)

the name __init_Foo40399160 changes to __init_Foo40399260

So, how is/was the name chosen?  I cannot produce this on more recent
compilers, has this changed (can this still occur for more complex
examples)?   The reason this is asked is that this is checked (the
executable) via differences against the odump output from different
builds, and these names tend to change for the simplist of things
(include order, added comments and such).

Thanks for any help.

---Foo.h---
#include <stream.h>
#include <stdio.h>

class Foo
{
public:
        Foo();
        ~Foo();

        void set(const int);
        void print();

private:
        int val;
};

---Foo.C---
#include "Foo.h"

Foo::Foo()
{
        val = 1;
}
Foo::~Foo()
{
}

void
Foo::set(const int new_val)
{
        val = new_val;
}

void
Foo::print()
{
        cout << "value: " << val << endl;
}
---ex1.C---
#include <stdio.h>
#include <stream.h>
#include "Foo.h"

main()
{
        Foo f;
        int i = 3;

        f.set(i);

        f.print();

        cout << "You fixed it!" << endl;

        return 0;
}

cxx -g -o foo Foo.C ex1.C
T.RTitleUserPersonal
Name
DateLines
3553.1CXXC::PHILLIPSThu Apr 24 1997 18:547
>So, how is/was the name chosen?

Its an internally generated number (actually, an address) that
cannot be counted on to be the same from one compilation to the
next.

3553.2CSC64::BLAYLOCKIf at first you doubt,doubt again.Thu Apr 24 1997 19:324

Many thanks.  I presume that this naming convention still occurs in
later compiler releases?
3553.3a not so definitive answerDECC::OUELLETTEmudseason into blackfly seasonThu Apr 24 1997 23:476
I believe that the names chosen are less random in newer compilers.
That helps some test system things to work more easily.
Adding a line of code doesn't change all the subsequent lines and
changing compiler versions doesn't change the symbols names as much.
The new scheme may (I've not looked) number them starting at zero
or something like that...