Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-04

Self pointer existence

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Wimpie Nortje

Hi

When does the self pointer's value become valid?

I need a reference to the object being created inside the object's own create method. The last statement in Create uses self, but that causes program crashes.

Is this too early to use self? Is there another way?

Mattias Gaertner
to Wimpie Nortje
Hi When does the self pointer's value become valid?

In NewInstance, so before the constructor is called.

Show quoted text 5 lines
I need a reference to the object being created inside the object's own create method. The last statement in Create uses self, but that causes program crashes. Is this too early to use self? Is there another way?

There is probably a bug in your code, but without seeing the code there is no way to tell.

Mattias

Wimpie Nortje
to Mattias Gaertner

Thanks

There is probably a bug in your code, but without seeing the code there is no way to tell.

It was something to do with converting strings to pchar before passing to a C library. Looks like it is fixed now