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

Codechange: Implement a constructor for CurrencySpec (fixes VS2017 compile failure) #8607

Merged
merged 2 commits into from Feb 13, 2021

Conversation

glx22
Copy link
Contributor

@glx22 glx22 commented Jan 25, 2021

Motivation / Problem

VS2017 fails to compile our current code with

  Error: ..\src\currency.cpp(69): error C2440: 'initializing': cannot convert from 'const char [3]' to 'char'
  ..\src\currency.cpp(69): note: There is no context in which this conversion is possible

While the error is weird (and probably incorrect as VS2019 has no issue with our code), I think implicit copy from const char[] (string literal) to char[] is not fully legit.

Description

I added a constructor to do the copy without implicit casting.
Of course that removed the default constructor, so I re-added it.
And with that VS2017 succeeds to build

Limitations

None I can think of.

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

LordAro
LordAro previously approved these changes Jan 25, 2021
Copy link
Member

@LordAro LordAro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LordAro
Copy link
Member

LordAro commented Jan 25, 2021

Should we add windows-2016 to the CI, perhaps?

@glx22
Copy link
Contributor Author

glx22 commented Jan 25, 2021

It's easy to enable both, test running on https://github.com/glx22/OpenTTD/actions/runs/510045181

@LordAro
Copy link
Member

LordAro commented Jan 25, 2021

Might as well, I'd say. Not like there's extra expense or anything :)

@glx22 glx22 merged commit f181037 into OpenTTD:master Feb 13, 2021
@glx22 glx22 deleted the string_literal branch February 13, 2021 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants