Path: chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: "Wayne K. Werner" Newsgroups: scea.yaroze.programming.codewarrior Subject: Re: __static_init conflict Date: 7 Jul 1997 03:47:59 GMT Organization: SCEA Net Yaroze News Lines: 46 Message-ID: <01bc8a88$99e77740$d3bf43ce@wkwerner> References: <01bc8964$21353000$94bf43ce@wkwerner> NNTP-Posting-Host: port111.con2.com X-Newsreader: Microsoft Internet News 4.70.1155 >Graeme Evans replied to me by email: > > I always thought that _static_init was in the C++ library along with new > and delete. And so isnt in beta 2. I hope im wrong. > > I got _static_init working alright in beta 1. It was only declared in > _psstart.c, so if I were you i'd get rid of the other one. Its only called > in _psstart.c I think - have a look further down the file in the start > code, that might tell you which definition to use. > >Graeme The function is either completely supplied by the linker, or a pointer to the function is supplied by the linker, and the function is supplied to the linker by the compiler (? maybe some link specification to the compiled function?) or again completely by the linker. The function is called as follows in _psstart.c: #ifdef __cplusplus /* C++ static initializer. The symbol __static_init is */ /* defined by the linker */ __static_init(); #endif As always, in C/C++, this is an area ambiguity. I can not tell from this whether the intent is to call the function via a pointer to that function or from the symbolic name of the function. Function name mangling, however does not occur on function pointers, but on function names themselves. This is why the declaration in _psstart.c, where __static_init is declared as a function, must be extern "C" if __static_init is to be found by the linker. The __rts_info_t__.h file declaration as a function pointer has no such linkage problems. The question remains: Only one of these is valid. Is the linker symbol the address of a pointer to a linker supplied function, or is the linker symbol the address of the function itself? I have assumed that the answer is a pointer to the function. I have commented out the declaration in _psstart.c. So far, I have things linking and appearing to work, however I would like a definitive answer to this from someone in MW (is there anybody out there?) Wayne