Sign in Join

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

Mailing lists / fpc-pascal / 2011-08

Virtual inline methods

5 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

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

Unknown author

ZeelandNet Webmail

I'm porting a piece of code from C++ and
there they use virtual inline methods. I tried it in FPC but it accepts either virtual OR inline methods. Is this a bug, or a feature that I don't understand enough about?

Regards, Darius

Reply by email

Jonas Maebe
to Unknown author

On 18 Aug 2011, at 17:08, <

Show quoted text 7 lines
wrote: I'm porting a piece of code from C++ and there they use virtual inline methods. I tried it in FPC but it accepts either virtual OR inline methods. Is this a bug, or a feature that I don't understand enough about?

FPC cannot inline virtual methods under any circumstances (even though in some special cases it would be theoretically possible, such as with final virtual methods or when using whole-program optimization), so it doesn't make sense to allow declaring them.

Jonas

Reply by email

Vincent Snijders
to Unknown author: ZeelandNet Webmail I'm porting a piece of code from C++ and there they use virtual inline…

2011/8/18 :

I'm porting a piece of code from C++ and there they use virtual inline methods. I tried it in FPC but it accepts either virtual OR inline methods. Is this a bug, or a feature that I don't understand enough about?

At first I didn't understand how a virtual function can be inlined (in C++), but after reading
http://msdn.microsoft.com/en-us/magazine/cc301407.aspx I understand.

I think fpc is not optimizing so much that it can detect when a virtual function can be inlined. But maybe WPO
(http://wiki.freepascal.org/Whole_Program_Optimization) can do something similar.

Vincent

Reply by email

Unknown author
to Unknown author: ZeelandNet Webmail I'm porting a piece of code from C++ and there they use virtual inline…
Show quoted text 6 lines
ZeelandNet Webmail I'm porting a piece of code from C++ and there they use virtual inline methods. I tried it in FPC but it accepts either virtual OR inline methods. Is this a bug, or a feature that I don't understand enough about?

You can't inline virtual methods, since you don't know which method will be suspect C++ simply ignores the directive in the case of a virtual method.

Michael.

Reply by email

Darius Blaszyk
to Vincent Snijders: 2011/8/18 : At first I didn't understand how a virtual function can be inlined (in C++),…

Thanks all for the information. I will have a read to understand the backgrounds better.

Darius

Vincent Snijders wrote 19 lines
2011/8/18 : > > I'm porting a piece of code from C++ and there they use virtual inline > methods. I tried it in FPC but it accepts either virtual OR inline methods. > Is this a bug, or a feature that I don't understand enough about? At first I didn't understand how a virtual function can be inlined (in C++), but after reading http://msdn.microsoft.com/en-us/magazine/cc301407.aspx I understand. I think fpc is not optimizing so much that it can detect when a virtual function can be inlined. But maybe WPO (http://wiki.freepascal.org/Whole_Program_Optimization) can do something similar. Vincent _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email