Inline redefinition

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
Amaroker
Engineer
Engineer
Posts: 4
Joined: 10 Jun 2012 13:49

Inline redefinition

Post by Amaroker »

Hello everyone,

I'm new here. I found this in stdafx.h and squirrel.h:

Code: Select all

#if defined(_MSC_VER)
# define inline __forceinline 
#endif
Now, Visual Studio 2012 has strict control for redefining C++ keywords, thus compilation will fail.

I suggest:

Code: Select all

#if defined(_MSC_VER)
  #define INLINE __forceinline
#else
  #define INLINE inline
#endif
...as well as a lot of "inline" to "INLINE" replacements throughout the code.

Anyone up for this task, or should I do it myself? 8)
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Inline redefinition

Post by planetmaker »

quickest way is: provide a patch :-)
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Inline redefinition

Post by Alberth »

Some time ago, the inline macro was removed.
You may want to check that reason is now invalid.
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Inline redefinition

Post by Terkhen »

With regard to MSVC 2012, I read something about it having an express edition limited in compilation possibilities. Is it possible to compile OpenTTD with an express edition of MSVC 2012?
Amaroker
Engineer
Engineer
Posts: 4
Joined: 10 Jun 2012 13:49

Re: Inline redefinition

Post by Amaroker »

Some time ago, the inline macro was removed.
OK, I'll check (I didn't yet retrieve the latest SVN version).
Is it possible to compile OpenTTD with an express edition of MSVC 2012?
Don't know about that - I only tried with the professional edition.
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Inline redefinition

Post by Terkhen »

I'm asking about the express edition because if it is not able to compile OpenTTD then we will probably not be able to test your work.
Amaroker
Engineer
Engineer
Posts: 4
Joined: 10 Jun 2012 13:49

Re: Inline redefinition

Post by Amaroker »

OK, I see. I can test with the express edition some day soon.

Nevertheless, I'm writing standard C++ code, not using Microsoft language extensions. However, with VS2012 I'm of course tempted to use new supported C++11 features like lambda functions and concurrency to improve performance and readability. I guess that's not acceptable for compatibility reasons with old compilers. The current code style is not very modern C++. Where do you draw the line? Does it have to build on some compiler X?
Terkhen
OpenTTD Developer
OpenTTD Developer
Posts: 1034
Joined: 11 Sep 2008 07:32
Location: Spain

Re: Inline redefinition

Post by Terkhen »

Thanks :)

See http://vcs.openttd.org/svn/browser/trun ... e.txt#L431 for a list of supported compilers. I can't help you with regard to which compilers support C++11 features and which ones don't. I also don't know if we need to avoid C++11 for compatibility.

With regard to Microsoft extensions, as long as they are not supported by most compilers in that list I know for sure that they are not an option for us :)
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Inline redefinition

Post by Yexo »

Amaroker wrote:OK, I see. I can test with the express edition some day soon.

Nevertheless, I'm writing standard C++ code, not using Microsoft language extensions. However, with VS2012 I'm of course tempted to use new supported C++11 features like lambda functions and concurrency to improve performance and readability. I guess that's not acceptable for compatibility reasons with old compilers. The current code style is not very modern C++. Where do you draw the line? Does it have to build on some compiler X?
I don't think we have a rule for this, but we still have a project file for MSVC 2005. While support for that version might be dropped sometime, it should definitely compile on 2008.
Amaroker
Engineer
Engineer
Posts: 4
Joined: 10 Jun 2012 13:49

Re: Inline redefinition

Post by Amaroker »

Thanks for the replies. OK, I can live with that for now :-)

Until the compilers catch up, I can see there is much other maintenance needed. Running the analyze tool of VS2012 shows a great lot of possible memory leaks and other warnings. CLANG will probably find even more. So, I will download the express version and start patching :-)
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: Inline redefinition

Post by Rubidium »

Amaroker wrote:Running the analyze tool of VS2012 shows a great lot of possible memory leaks and other warnings.
With VS2010 the vast majority of these 'possible memory leaks' were false positives; we use Vehicle *v = new Vehicle(); to put something in a pool, but then don't delete it before v goes out of scope. The compiler thinks it leaks memory, but in fact it does not because new (or the constructor) silently adds the allocated memory to a lookup table.
User avatar
orudge
Administrator
Administrator
Posts: 25137
Joined: 26 Jan 2001 20:18
Skype: orudge
Location: Banchory, UK
Contact:

Re: Inline redefinition

Post by orudge »

I read that the Express edition of VC 2012 will only allow you to build Metro applications, and not standard Windows desktop applications.

It also seems to be the case that the VC 2012 compiler will only generate binaries that work on Vista or later, and not XP SP3 (or, indeed, earlier versions, which are already unsupported by VC 2010).
User avatar
Digitalfox
Chief Executive
Chief Executive
Posts: 708
Joined: 28 Oct 2004 04:42
Location: Catch the Fox if you can... Almost 20 years and counting!

Re: Inline redefinition

Post by Digitalfox »

orudge wrote:I read that the Express edition of VC 2012 will only allow you to build Metro applications, and not standard Windows desktop applications.

It also seems to be the case that the VC 2012 compiler will only generate binaries that work on Vista or later, and not XP SP3 (or, indeed, earlier versions, which are already unsupported by VC 2010).
Microsoft stepped back and now VC 2012 Express will compile desktop applications.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 35 guests