Re: [fpc-pascal] Type-casting a class variable

2024-05-02 Thread Adriaan van Os via fpc-pascal
In addition to what Martin said: as long as you have a non-static class method the value of the variable you call the class method on (e.g. myClass in your example) will be passed as Self parameter. So no need for extra parameters. But how can myClass be passed ?

Re: [fpc-pascal] Type-casting a class variable

2024-05-02 Thread Adriaan van Os via fpc-pascal
Martin Frb via fpc-pascal wrote: Silly question, but did you assign the value to the variable? myClass := TWindow; That's what I did. TWindow(myClass).CreateNewWindow; And this is what crashes. I can report this, if the type-cast is supposed to work. Regards, Adriaan van Os

Re: [fpc-pascal] Type-casting a class variable

2024-05-02 Thread Adriaan van Os via fpc-pascal
Olivier Sannier via fpc-pascal wrote: Hello, You should cast to TWindowClass as TWindow is used to cast an instance, not a class reference. Note that you may not have TWindowClass, in which case you need to declare it like this: type TWindowClass = class of TWindow; OK. A typecast

Re: [fpc-pascal] Type-casting a class variable

2024-05-02 Thread Adriaan van Os via fpc-pascal
Martin Frb via fpc-pascal wrote: My example (2nd part of it) was actually wrong. It was mentioned before On 01/05/2024 19:43, Jean SUZINEAU via fpc-pascal wrote: I didn't tested but I imagine it could be done with something like this ? type TWindow_Class= class of TWindow; begin

[fpc-pascal] FPC 3.3.x breaks the Firebird Project's Firebird.pas

2024-05-02 Thread Tony Whyman via fpc-pascal
This is a problem reported to me by an IBX user. I have not yet confirmed it (need to find the time to set up the latest development branch of FPC), but the issue looks solid, and is due to the following addition to TObject (copied from the GitLab master branch) |TObject = class|{$IFDEF

Re: [fpc-pascal] Type-casting a class variable

2024-05-02 Thread Martin Frb via fpc-pascal
On 02/05/2024 08:32, Adriaan van Os via fpc-pascal wrote: Martin Frb via fpc-pascal wrote: Silly question, but did you assign the value to the variable? myClass := TWindow; That's what I did. TWindow(myClass).CreateNewWindow; And this is what crashes. I can report this, if the type-cast

Re: [fpc-pascal] Type-casting a class variable

2024-05-02 Thread Olivier Sannier via fpc-pascal
Hello, You should cast to TWindowClass as TWindow is used to cast an instance, not a class reference. Note that you may not have TWindowClass, in which case you need to declare it like this: type     TWindowClass = class of TWindow; Note that CreateNewWindow would have to be virtual for

Re: [fpc-pascal] FPC 3.3.x breaks the Firebird Project's Firebird.pas

2024-05-02 Thread Michael Van Canneyt via fpc-pascal
On Thu, 2 May 2024, Tony Whyman via fpc-pascal wrote: This is a problem reported to me by an IBX user. I have not yet confirmed it (need to find the time to set up the latest development branch of FPC), but the issue looks solid, and is due to the following addition to TObject (copied from

Re: [fpc-pascal] Type-casting a class variable

2024-05-02 Thread Marco van de Voort via fpc-pascal
Op 2-5-2024 om 08:32 schreef Adriaan van Os via fpc-pascal: TWindow(myClass).CreateNewWindow; And this is what crashes. I can report this, if the type-cast is supposed to work. Known gotcha. Is and as are no good for method variables, use: if myclass.inheritsfrom(twindow) then