Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix __forceinline in Visual Studio 2012 #5375

Closed
DorpsGek opened this issue Nov 26, 2012 · 13 comments
Closed

Fix __forceinline in Visual Studio 2012 #5375

DorpsGek opened this issue Nov 26, 2012 · 13 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay

Comments

@DorpsGek
Copy link
Member

NG opened the ticket and wrote:

Implements the suggestion from http://www.tt-forums.net/viewtopic.php?f=33&t=61266, tested with 64-bit Windows 8 Ultimate.

Attachments

Reported version: trunk
Operating system: Windows


This issue was imported from FlySpray: https://bugs.openttd.org/task/5375
@DorpsGek
Copy link
Member Author

LordAro wrote:

Wasn't this 'unfixed' in r23640? http://hg.openttd.org/openttd/trunk.hg/rev/aa20e2f1c847


This comment was imported from FlySpray: https://bugs.openttd.org/task/5375#comment11718

@DorpsGek
Copy link
Member Author

NG wrote:

That's the one.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5375#comment11719

@DorpsGek
Copy link
Member Author

Alberth wrote:

First of all, why should we revert the change?

Secondly, the patch seems to bluntly replace 'inline' with 'INLINE'. Did you verify whether each routine is actually useful to inline? I would be very amazed if that would actually be the case.

Thirdly, if you add forcing to inline a function, how will you manage that for all platforms that we have (ie the general form would be "inline this function for that and that platform, not for this one, and I don't care for the other ones"). Your patch does not seem to support that notion, nor do I see a sane way to do that, nor would I know how to decide which function to inline when.

I trust compilers more than ourselves in deciding what to inline, especially with the wide range of platforms that are supported.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5375#comment11720

@DorpsGek
Copy link
Member Author

NG wrote:

I didn't say anything specifically about reverting, just that the problem starts after that revision, and certainly didn't look at each individual function.
If all you'd like is to let the compiler make the decisions in every case, only that one "# define inline __forceinline" needs to be taken out.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5375#comment11721

@DorpsGek
Copy link
Member Author

NG wrote:

Perhaps change the ticket to "Stop using __forceinline"?


This comment was imported from FlySpray: https://bugs.openttd.org/task/5375#comment11812

@DorpsGek
Copy link
Member Author

DorpsGek commented Mar 2, 2013

NG wrote:

So once again, if the "# define inline __forceinline" bits are taken out of squirrel.h and stdafx.h, there are no errors or warnings at all. This also seems to be what you wanted all along.
The only thing I haven't tested is DirectMusic, which is entirely unnecessary anyway.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5375#comment12071

@DorpsGek
Copy link
Member Author

NG wrote:

Well, looks like I pushed the developer silencing button...


This comment was imported from FlySpray: https://bugs.openttd.org/task/5375#comment12109

@DorpsGek
Copy link
Member Author

Alberth wrote:

Somewhat. Most devs (including me) don't use windows, which makes it very awkward to do anything with such patches.

I wonder what happens with the window builds that do not use VS 2012. That line was not added to the source code for nothing.

To be on the safe side, I guess your removal should only be done when you use the new VS version.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5375#comment12155

@DorpsGek
Copy link
Member Author

NG wrote:

Better this way?

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5375#comment12156

@DorpsGek
Copy link
Member Author

adf88 wrote:

There is a macro for these purposes (disabling the <xkeychk.h> check): _ALLOW_KEYWORD_MACROS

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5375#comment12430

@DorpsGek
Copy link
Member Author

LordAro wrote:

I'd recommend going with the "Stop using __forceinline" option

Especially since it still doesn't guarantee the function being inlined ( https://msdn.microsoft.com/en-us/library/bw1hbe6y.aspx ) and the compiler generally knows better than you (tm) anyway


This comment was imported from FlySpray: https://bugs.openttd.org/task/5375#comment14555

@DorpsGek
Copy link
Member Author

adf88 wrote:

I'm not saying that I'm against removing __forceinline, but it's not a problem that it doesn't guarantee actual code inlining. __forceinline says "don't perform cost analysis, create an in-line definition only if possible".

The 'inline' keyword, except of its language meaning, sometimes affects the compiler cost analysis on code in-lining e.g. see http://stackoverflow.com/questions/27042935/inline-keyword-vs-inlining-concept. The macro makes MSVC more similar to them.

Programmers tend to use 'inline' to say "try harder at code inlining". You may be of course against this practice (abusing 'inline' keyword) but it's already in motion anyway.

The __forceinline might have to do also with the MSVC code generation options - maybe it's to compensate the "optimize for code size" option (not sure).


This comment was imported from FlySpray: https://bugs.openttd.org/task/5375#comment14578

@DorpsGek
Copy link
Member Author

DorpsGek commented Sep 2, 2017

andythenorth closed the ticket.

Reason for closing: Won't implement

Flyspray clean up, issue has aged, there is no sign that it's still relevant to anyone, closing. Thanks.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5375

@DorpsGek DorpsGek closed this as completed Sep 2, 2017
@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) Build system patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay
Projects
None yet
Development

No branches or pull requests

1 participant