Skip to content

fix: Resolve macro redefinition warnings#2525

Open
Skyaero42 wants to merge 5 commits intoTheSuperHackers:mainfrom
Skyaero42:fix/macro-redefined-warning
Open

fix: Resolve macro redefinition warnings#2525
Skyaero42 wants to merge 5 commits intoTheSuperHackers:mainfrom
Skyaero42:fix/macro-redefined-warning

Conversation

@Skyaero42
Copy link
Copy Markdown

@Skyaero42 Skyaero42 commented Apr 2, 2026

NUM_ALPHA_TILES in Generals\Wheightmapedit.h was unused and is removed
_WIN32_WINNT was unused and is removed
WIN32_LEAN_AND_MEAN was redefined in registry.cpp. Included win.h instead, which already handles this macro correctly.

…rnings.

Added guards for WIN32_LEAN_AND_MEAN, _WIN32_WINNT, and
NUM_ALPHA_TILES to prevent redefinition.

- Related to TheSuperHackers#499
- Related to TheSuperHackers#503
@Skyaero42 Skyaero42 added this to the Code foundation build up milestone Apr 2, 2026
@Skyaero42 Skyaero42 self-assigned this Apr 2, 2026
@Skyaero42 Skyaero42 added the Stability Concerns stability of the runtime label Apr 2, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 2, 2026

Greptile Summary

This PR correctly fixes three macro redefinition warnings with no behavioral impact. WIN32_LEAN_AND_MEAN in registry.cpp is replaced with win.h which guards the macro correctly, _WIN32_WINNT 0x0400 is removed from thread.cpp (already defined at the build level), and the duplicate NUM_ALPHA_TILES 8 is removed from WHeightMapEdit.h (the authoritative definition of 12 lives in WorldHeightMap.h).

Confidence Score: 5/5

Safe to merge — all changes are straightforward macro cleanup with no behavioral impact

Only P2 findings remain (redundant include). All three macro removals are correct and do not affect runtime behavior.

No files require special attention

Important Files Changed

Filename Overview
Core/Libraries/Source/WWVegas/WWDownload/registry.cpp Replaces manual WIN32_LEAN_AND_MEAN + windows.h with win.h include; redundant include left behind
Core/Libraries/Source/WWVegas/WWLib/thread.cpp Removes stale _WIN32_WINNT 0x0400 macro define that caused redefinition warnings
Generals/Code/Tools/WorldBuilder/include/WHeightMapEdit.h Removes duplicate NUM_ALPHA_TILES 8 macro that conflicted with NUM_ALPHA_TILES 12 in WorldHeightMap.h

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[registry.cpp] --> B[Registry.h]
    A --> C[win.h]
    B --> D[string]
    C --> E[WIN32_LEAN_AND_MEAN guard]
    E --> F[windows.h]
    G[thread.cpp] --> H[thread.h]
    G --> I[windows.h via ifdef _WIN32]
    J[WHeightMapEdit.h] --> K[WorldHeightMap.h]
    K --> L[NUM_ALPHA_TILES = 12]
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: Core/Libraries/Source/WWVegas/WWDownload/registry.cpp
Line: 24

Comment:
**Redundant `<string>` include**

`Registry.h` (included on the previous line) already includes `<string>`, making this include redundant.

```suggestion
#include <win.h>
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (5): Last reviewed commit: "refactor: sort includes" | Re-trigger Greptile

@bobtista
Copy link
Copy Markdown

bobtista commented Apr 2, 2026

Could we use add_compile_definitions(WIN32_LEAN_AND_MEAN) in cmake and clean up all the individual defines?

@xezon xezon added CompileBug Bug at compile time Fix Is fixing something, but is not user facing and removed Stability Concerns stability of the runtime labels Apr 3, 2026
@xezon
Copy link
Copy Markdown

xezon commented Apr 3, 2026

The Pull title needs some polishing.

@Skyaero42 Skyaero42 changed the title fix: Add preprocessor guards around macros to resolve redefinition warnings. fix: Resolve redefinition warnings of macro's Apr 4, 2026
@Skyaero42
Copy link
Copy Markdown
Author

The Pull title needs some polishing.

done

@Skyaero42 Skyaero42 requested a review from xezon April 4, 2026 16:28
Also sorting includes by alphabetic order
@xezon xezon changed the title fix: Resolve redefinition warnings of macro's fix: Resolve macro redefinition warnings Apr 5, 2026
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#include <win.h>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

"win.h"

Sort alphabetically.

Copy link
Copy Markdown
Author

@Skyaero42 Skyaero42 Apr 6, 2026

Choose a reason for hiding this comment

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

Was wondering already whether that would be in scope or not. Its done now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CompileBug Bug at compile time Fix Is fixing something, but is not user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants