Skip to content

Conversation

@zzambers
Copy link

@zzambers zzambers commented Mar 30, 2025

Fixes code to be buildable using MinGW. Contains only fixes to game code. Does add support of MinGW to build system (cmake files) or any CI testing yet.

Partially fixes: #486

@zzambers zzambers marked this pull request as draft March 30, 2025 02:32
@Mauller Mauller added 🚫Do Not Merge Build Anything related to building, compiling ZH Relates to Zero Hour labels Mar 30, 2025
@Mauller
Copy link

Mauller commented Mar 30, 2025

There are VC6 breaking changes in this due to the use of c++11 features.

If those are required then this cannot be used yet.

Marked do not merge for now.

@zzambers
Copy link
Author

zzambers commented Mar 30, 2025

There are VC6 breaking changes in this due to the use of c++11 features.

If those are required then this cannot be used yet.

Marked do not merge for now.

Thanks, this is definitely not yet ready for merge :)

Yes, I was afraid that enum Name : int syntax is probably not supported by VC6, but tried it anyway. So I'll probably need to go for macros and #ifdefs to fix forward enum declarations. :( (untyped forward declarations of enums are VC extension and typed ones are since c++11 and not supported by VC6...)

Maybe macro like IENUM(Name), INT_ENUM(Name) or ENUM_INT(Name) can be crated...

@xezon
Copy link

xezon commented Mar 30, 2025

Maybe macro like IENUM(Name), INT_ENUM(Name) or ENUM_INT(Name) can be crated...

Perhaps create a univeral macro

#if __cplusplus >= 201103L
    #define CPP_11(code) code
#else
    #define CPP_11(code)
#endif

Used as

enum EnumName CPP_11(: int)
{
}

Then this macro can be used for different things concerning c++11 features.

Or make it enum specific with

#if __cplusplus >= 201103L
    #define ENUM_UNDERLYING(type) : type
#else
    #define ENUM_UNDERLYING(type)
#endif

@zzambers
Copy link
Author

zzambers commented Mar 30, 2025

Maybe macro like IENUM(Name), INT_ENUM(Name) or ENUM_INT(Name) can be crated...

Perhaps create a univeral macro

#if __cplusplus >= 201103L
    #define CPP_11(code) code
#else
    #define CPP_11(code)
#endif

Interesting idea with universal CPP_11 macro, I quite like it. :)

@zzambers
Copy link
Author

zzambers commented Mar 30, 2025

@xezon I addapted approch with CPP_11 macro you suggested. thanks

Finally made it compile on VC6, I'll clean it up later for easier review (rebasing, combining related commits together, better commit messages etc..) I expect asm replacements to be merged to main first, I'll then rebase my changes on top.

If you prefer, I can also make fix of enums (forward declarations) separate PR. (as it is quite a big change set)

@xezon xezon added this to the Code foundation build up milestone Mar 31, 2025
@zzambers zzambers mentioned this pull request Mar 31, 2025
17 tasks
//
// typelib filename: <could not determine filename>

import "oaidl.idl";
Copy link

Choose a reason for hiding this comment

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

This file was already moved to Core folder so you will need to replicate this there.

//
// typelib filename: <could not determine filename>

import "oaidl.idl";
Copy link

Choose a reason for hiding this comment

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

The IDL file was generated by a tool. Perhaps add a fat comment here that this has been added by hand.

Copy link
Author

Choose a reason for hiding this comment

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

Error by widl is:

BrowserEngine.idl:31:44: error: type 'IDispatch' not found in global namespace

    interface IFEBrowserEngine2 : IDispatch {
                                           ^

IDispatch is in oaidl.idl in wine headers.

Copy link
Author

Choose a reason for hiding this comment

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

Same with MinGW headers. (IDispatch is in oaidl.idl)

#pragma once

#include <cassert>
#define UNIMPLEMEMTED_ERROR(msg) do { \
Copy link

Choose a reason for hiding this comment

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

UNIMPLEMENTED_ERROR

Copy link
Author

Choose a reason for hiding this comment

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

Oh, I had to read it several times to spot the typo :) I'll fix that.

#include "GameClient/IMEManager.h"
#include "Win32Device/GameClient/Win32Mouse.h"
#include "Win32Device/Common/Win32GameEngine.h"
#include "WWLib/trim.h"
Copy link

Choose a reason for hiding this comment

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

Typing error in commit title:

"[ZH] Removal of duplicit strtrim"

"duplicate"

Copy link
Author

Choose a reason for hiding this comment

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

Ah, that's probably not an English world, sorry. :) However, I think, this has already been addressed by other PR already in meantime...

Copy link

Choose a reason for hiding this comment

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

How do you plan to replicate these changes if we decide to merge this before we move things to Core?

Right now the amount of single commits is massive. Replicating this equally to Generals would mean 64 commits for this effort.

Perhaps combine some of the smaller commits into new commits, and also add Generals changes to each Zero Hour change commit once we are happy with Zero Hour? This could perhaps get the commit count down to 24 or so.

Each of the commits needs to be able to compile on their own.

Copy link
Author

@zzambers zzambers Apr 12, 2025

Choose a reason for hiding this comment

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

Originally I was just planning to do ZH as whole, followed by backport to GEN. But I see, there is quite a lot of activity in this project, causing code to diverge quickly. Also sometimes other efforts (like fixes of warnings) address same things, as this PR.

So now, I am considering breaking this into multiple smaller PRs, (which would probably be [GEN][ZH]). I have seen others following similar approach for their PRs. I would not like to end up in endless rebase loop. :)

Copy link
Author

Choose a reason for hiding this comment

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

I'll probably do bigger change sets as separate PRs (referencing discussions here), hopefully this one will then have more manageable size...

Copy link

@Mauller Mauller Apr 12, 2025

Choose a reason for hiding this comment

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

The Enum one should be a PR of its own considering how many fines it hits.

Just taking that one out will cleanup a lot of this.

EDIT: NVm i just saw that you did exactly that.

Copy link

Choose a reason for hiding this comment

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

I second this. Let us get the enum fixes in one single Pull Request, without anything else. A lot of things are going into main line right now, so you want to keep the amount of things that happen inside the Pull Request small, so it can get reviewed swiftly.

@xezon xezon added Major Severity: Minor < Major < Critical < Blocker and removed 🚫Do Not Merge labels Apr 10, 2025
@Mauller
Copy link

Mauller commented Apr 12, 2025

At level 4 warnings, the untyped enumerations actually create nearly 10k worth of warnings, a lot of it due to the forward declarations in headers.

@zzambers
Copy link
Author

@xezon @Mauller @OmniBlade @DevGeniusCode Thank you for your reviews.

As I have written higher I'll try to separate parts of this into new PRs, to keep this manageble size. (Possibly using this PR for of smaller changes.) I'll address raised issues there, linking this PR with reviews.

I'll post link to new derived PRs here

@zzambers
Copy link
Author

zzambers commented Apr 12, 2025

Fixes to forward enum declarations: #665

@zzambers
Copy link
Author

Rest of asm made VC only: #670

@zzambers
Copy link
Author

Fixes to intrin_compat.h: #671

@zzambers
Copy link
Author

COM related fixes: #672

@Caball009
Copy link

A number of changes are also a part of the PR for clang-cl compilation: #888

@xezon
Copy link

xezon commented Jun 23, 2025

This change is severely outdated by now.

@Mauller
Copy link

Mauller commented Jul 15, 2025

Is this still having work done to it?

With recent changes needed for clang build support, this PR may be significantly simplified when rebased.

@Skyaero42
Copy link

@zzambers Is this something you still want to work on?

JohnsterID pushed a commit to JohnsterID/GeneralsGameCode that referenced this pull request Jan 4, 2026
Prevent Windows headers from defining min/max macros that conflict
with C++ code. Minimal change following PR TheSuperHackers#547 approach - only adds
guard, keeps existing min/max macro definitions with their #ifndef guards.

Co-authored-by: openhands <openhands@all-hands.dev>
JohnsterID pushed a commit to JohnsterID/GeneralsGameCode that referenced this pull request Jan 4, 2026
Following PR TheSuperHackers#547 minimal approach:
- Add #ifndef guard around NOMINMAX to prevent redefinition warnings
- Wrap min/max template functions with _MIN_MAX_TEMPLATES_DEFINED_ guard
  to prevent conflicts when included multiple times

This works with BaseTypeCore.h's NOMINMAX + existing #ifndef guards to
resolve all min/max macro/template conflicts.

Co-authored-by: openhands <openhands@all-hands.dev>
JohnsterID pushed a commit to JohnsterID/GeneralsGameCode that referenced this pull request Jan 4, 2026
…re.h

- Change min(x,y) to MIN(x,y) macro definition
- Change max(x,y) to MAX(x,y) macro definition
- Remove NOMINMAX definition (no longer needed with uppercase macros)
- Prevents conflicts with C++ template functions from STL
- Part of MinGW compatibility improvements following PR TheSuperHackers#547 approach
JohnsterID pushed a commit to JohnsterID/GeneralsGameCode that referenced this pull request Jan 4, 2026
- Add conditional compilation for MinGW to use STL's min/max functions
- Preserve MSVC custom template implementations
- Use 'using std::min; using std::max;' for MinGW compatibility
- Prevents multiple definition errors when linking with MinGW
- Aligns with PR TheSuperHackers#547 approach for MinGW compatibility
- Maintains VC6 and MSVC compatibility with existing custom templates
JohnsterID added a commit to JohnsterID/GeneralsGameCode that referenced this pull request Jan 4, 2026
Prevent Windows headers from defining min/max macros that conflict
with C++ code. Minimal change following PR TheSuperHackers#547 approach - only adds
guard, keeps existing min/max macro definitions with their #ifndef guards.
JohnsterID added a commit to JohnsterID/GeneralsGameCode that referenced this pull request Jan 4, 2026
Following PR TheSuperHackers#547 minimal approach:
- Add #ifndef guard around NOMINMAX to prevent redefinition warnings
- Wrap min/max template functions with _MIN_MAX_TEMPLATES_DEFINED_ guard
  to prevent conflicts when included multiple times

This works with BaseTypeCore.h's NOMINMAX + existing #ifndef guards to
resolve all min/max macro/template conflicts.
JohnsterID added a commit to JohnsterID/GeneralsGameCode that referenced this pull request Jan 4, 2026
…re.h

- Change min(x,y) to MIN(x,y) macro definition
- Change max(x,y) to MAX(x,y) macro definition
- Remove NOMINMAX definition (no longer needed with uppercase macros)
- Prevents conflicts with C++ template functions from STL
- Part of MinGW compatibility improvements following PR TheSuperHackers#547 approach
JohnsterID added a commit to JohnsterID/GeneralsGameCode that referenced this pull request Jan 4, 2026
- Add conditional compilation for MinGW to use STL's min/max functions
- Preserve MSVC custom template implementations
- Use 'using std::min; using std::max;' for MinGW compatibility
- Prevents multiple definition errors when linking with MinGW
- Aligns with PR TheSuperHackers#547 approach for MinGW compatibility
- Maintains VC6 and MSVC compatibility with existing custom templates
JohnsterID added a commit to JohnsterID/GeneralsGameCode that referenced this pull request Jan 5, 2026
MinGW-w64 (GCC) does not allow implicit conversion from function pointers
to void*. Added explicit (void*) casts to all function pointer entries in
the FunctionLexicon lookup tables for both Generals and GeneralsMD.

This follows the same approach used in PR TheSuperHackers#547 for MinGW compatibility
while maintaining VC6 compatibility with minimal code changes.
JohnsterID added a commit to JohnsterID/GeneralsGameCode that referenced this pull request Jan 5, 2026
Include stddef.h to ensure size_t is properly defined for MinGW builds.
This prevents compilation errors where size_t is used but not declared.

This fix is based on PR TheSuperHackers#547 by zzambers which addresses MinGW
compilation issues throughout the codebase.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Build Anything related to building, compiling Major Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make project buildable using MinGW toolchain

7 participants