-
-
Notifications
You must be signed in to change notification settings - Fork 172
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
Build everything as C++ #1176
Build everything as C++ #1176
Conversation
adf5053
to
271affa
Compare
Those CI errors are certainly confusing. Why is DLL list corrupted somehow? As for |
|
You mean how the two 32-bit windows-xtesting CI runs give lots of |
c90e27f
to
2ab4787
Compare
Blocked by choosing a solution to #1002. |
Unblocked! |
57244cd
to
b1a4105
Compare
Looks like Visual Studio doesn't support designated array initializers in C++, period; CI fails with a lot of " Edit: "This feature has been implemented in MSVC under If nothing else, we can replace |
Are we passing that flag? Looks like CMake is generating |
@ISSOtm Even passing |
Aha, got it! C++20 added designated initialisers for structs, but not for arrays!
Rather, the macro should only be defined for |
6a3c51f
to
80b5478
Compare
The 32-bit windows-xtesting CI builds fail (but not the 64-bit ones). When it's running the rgbfix test script, it keeps complaining:
This means the test cases aren't getting rgbfixed and so we get a lot of spurious .bin diff output. Looking into this as an issue with the Edit: Putting back C-specific directives in CMakeLists.txt didn't help. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one background concern with this PR: it's a big change, it carries a lot of risk (currently, the best example is the miscompilation under MinGW for 32-bit), and it may annoy downstream packagers.
But that doesn't mean we should throw any of this work away. Instead, I want to consider whether switching to C++ would enable any of the changes we have scheduled for 0.7.0—and I believe "enables feasibility for the launch window" counts as enabling.
If it does, then let's keep going ahead. But if it doesn't, I'd like to consider the possibility of buffering this PR until right after the 0.7.0 release.
The rationale for my being chilly here, is that if we're going to move to Rust in one of the next few releases, we may want to play nice with packagers, and avoid causing them extra work several times over.
Though maybe nont of that is a concern if the duration between 0.7.0 and the first Rust release ends up being similar to between 0.6.1 and 0.7.0 😆
@ISSOtm I'm more optimistic about making this switch before 0.7.0 releases. We already required a C++ compiler in the build for rgbgfx, so packagers have accounted for that. And as soon as we do convert to C++ I plan to try fixing some memory leaks and string length limits. That said, I specifically set the 0.7.0 milestone tasks to be ones we can do quickly (and mostly have), without needing C++ to make them easier to implement. The MinGW 32-bit issue is weird. I'll try and find the root cause and see if it was some one-off mistake, or a case of something about C++ compilation that really demonstrates a risk for other untested packaging environments. |
1ada664
to
6d127cd
Compare
@ISSOtm I fixed the MinGW 32-bit build error. rgbfix.exe was requiring some DLLs that we explicitly excluded from copying in the 32-bit version, one of which (libgcc_s_dw2-1.dll) doesn't even exist for the 32-bit CI run. (I tried I hope this won't prevent us merging the C++ PR. It was basically the same debugging difficulty as #1083 had, made annoying because of how you have to wait for GitHub Actions and read its logs in debugging steps. Note that |
Okay, that's fair then. |
I don't understand why the error message printed that as a single question mark, but I'm glad you figured it out somehow. |
This PR is just for the minimal changes required to compile as C++. But once it's merged, I'll do some further cleanup, like // Usage example:
// for (enum SectionType type : EnumSeq(SECTTYPE_INVALID)) { ... }
template<typename T>
class EnumSeqIterator {
T _value;
public:
explicit EnumSeqIterator(T value) : _value(value) {}
EnumSeqIterator &operator++() {
_value = (T)(_value + 1);
return *this;
}
auto operator*() const { return _value; }
friend auto operator==(EnumSeqIterator const &lhs, EnumSeqIterator const &rhs) {
return lhs._value == rhs._value;
}
friend auto operator!=(EnumSeqIterator const &lhs, EnumSeqIterator const &rhs) {
return lhs._value != rhs._value;
}
};
template<typename T>
class EnumSeq {
T _limit;
public:
explicit EnumSeq(T limit) : _limit(limit) {}
EnumSeqIterator<T> begin() { return EnumSeqIterator((T)0); }
EnumSeqIterator<T> end() { return EnumSeqIterator(_limit); }
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few remaining things, but this is practically mergeable.
The long-term goal here is to gradually convert the codebase to idiomatic C++. For example, we could get rid of the many reimplementations of dynamic arrays and just use
std::vector
.This PR just makes the minimal changes for it to build. That includes:
malloc
andrealloc
.-pedantic
, since we still have C-only nested anonymous structs and flexible array members, which are less trivial to replace.[[noreturn]]
instead of_Noreturn
.{}
instead of{0}
.goto
; move variables into a block or before thegoto
.struct
andenum
definitions to the top-level scope.+ 1
instead of++
.