Here's a snippet of code I use to call C++ constructors in crt0.S
I call it after clearing .bss and initializing .data:
/* Call global C++ object constructors */
ldr r4, =__CTOR_LIST__ @ Null terminated list of ctors
Ctor_Loop:
ldr r5, [r4], #+4 @ Fetch constructor address
cmp r5, #0 @ Test for end of list
addne lr, pc, #4 @ Save return address
movne pc, r5 @ Call constructor
bne Ctor_Loop @ Continue for all constructors
Good luck!
--- In lpc2000@yahoogroups.com, "Rodrigo Cesar da Silva Martins"
<rodrigo@i...> wrote:
> How can I use class constructors with gnu arm? I'm using a LPC2129 and
> Keil development system.
> For example:
> //header file
> class SPI
> {
> public:
> SPI(char init);
> .
> }
> //source file
> SPI::SPI(char init)
> {
> .
> }
> //application file
> SPI ADSPI(0); //spi channel for AD converter
>
> The constructor function should be called when I declare an object, but
> it doesn't happen.
>
> Thanks in advance,
> Rodrigo Martins
> Intermetric Instrumentos Ltda
> (11) 4761-8009
> rodrigo@i...
>
>
>
> [Non-text portions of this message have been removed]Message
Re: Constructors
2004-09-22 by dave_albert
Attachments
- No local attachments were found for this message.