This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Getting the address of a function in C++ with any egcs




Hi all,
 I have a problem getting the address of a C++ function with the egcs (any
version). With the gcc-2.7.2.3 it was possible.
Here a small test code:
------------------
#include <stdio.h>


class X {
 public:
        void test();
        virtual void test1();
};

class Y: public X {
  public:
        void test1();
};

void X::test()
{
        printf("%p\n", (char*)this->test);
}

void X::test1()
{
}

void Y::test1()
{
        printf("hallo\n");
}

void main()
{       X x;
        Y y;

        x.test();
        y.test();
        printf("%p\n", (char*)x.test1);
        printf("%p\n", (char*)y.test1);
}
---------------------------------
The output of the egcs-1.1 is:
----------------------------------
<12:07> aurel@od-solaris-3 <~> >g++ -v -O2 -Wall -o y y.cc
Reading specs from
/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.57/specs
gcc version egcs-2.91.57 19980901 (egcs-1.1 release)
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.57/cpp -lang-c++
-v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91
-Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__
-D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem(unix)
-Asystem(svr4) -D__EXCEPTIONS -D__OPTIMIZE__ -Wall -D__GCC_NEW_VARARGS__
-Acpu(sparc) -Amachine(sparc) y.cc /var/tmp/ccOPGC0f.ii
GNU CPP version egcs-2.91.57 19980901 (egcs-1.1 release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/g++
 /usr/local/lib/g++-include
 /usr/local/include
 /usr/local/sparc-sun-solaris2.5.1/include
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.57/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.57/cc1plus
/var/tmp/ccOPGC0f.ii -quiet -dumpbase y.cc -O2 -Wall -version -o
/var/tmp/ccVqEnxn.s
GNU C++ version egcs-2.91.57 19980901 (egcs-1.1 release)
(sparc-sun-solaris2.5.1) compiled by GNU C version egcs-2.91.57 19980901
(egcs-1.1 release).
y.cc: In method `void X::test()':
y.cc:17: warning: assuming & on `(*this) .* X::test()'
y.cc:17: cannot convert `X::test()' from type `void (X::*)()' to type `char
 *'
y.cc: At top level:
y.cc:30: warning: return type for `main' changed to `int'
y.cc: In function `int main(...)':
y.cc:35: warning: assuming & on `x .* X::test1()'
y.cc:35: cannot convert `X::test1()' from type `void (X::*)()' to type
`char *'
y.cc:36: warning: assuming & on `y .* Y::test1()'
y.cc:36: cannot convert `Y::test1()' from type `void (Y::*)()' to type
`char *'

--------------
I noticed the warnings but '&' does not change the error 'cannot convert
...'

When will it be possible to get the address of a function with egcs? (I
check egcs-1.1.1 on linux too with no success)

Anyway maybe someone can help me with my actuall problem:
I need the address of a function to find out the reloc-symbol name using
dladdr(). I need it for dynamic plug-in handling
where I check that the plug-in interface function is the same (has the same
 name which includes also the parameters
passed to the function due to the name mangeling) before calling the
function.

Regards,

     Aurel Balmosan




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]