Skip to content

Conversation

@Skyaero42
Copy link

@Skyaero42 Skyaero42 commented Oct 20, 2025

Automatically strip #ifndef/#define pairs and matching #endif that follow #pragma once in header files. Cleans up legacy patterns left from mixed guarding styles.

In order of commits:

  • Remove redundant ifndef/define pairs if pragma once is present
  • Special case for codex.h and related files that needed manual attention
  • Remove ifndef/define pairs and replace it with pragma once
  • Readjust linebreaks to ensure there is exactly one empty line before and one empty line after pragma once.

squash merge or rebase merge is both fine.

@Skyaero42 Skyaero42 self-assigned this Oct 20, 2025
@Skyaero42 Skyaero42 added the Refactor Edits the code with insignificant behavior changes, is never user facing label Oct 20, 2025
@xezon
Copy link

xezon commented Oct 21, 2025

Nice.

It looks like some are missing. For example #ifndef CARDINALSPLINE_H.

Before merging this change, we need another change first that removes all _MSC_VER tests around #pragma once (mostly present in WWVegas), because otherwise these headers will not compile on non MSC after the C include guards are removed.

#if defined(_MSC_VER)
#pragma once
#endif

to

#pragma once

@Skyaero42 Skyaero42 marked this pull request as draft October 21, 2025 07:23
@Skyaero42
Copy link
Author

Moving to draft to tackle MSC_VER guard of pragma first in a different PR.

@xezon
Copy link

xezon commented Oct 23, 2025

This change can continue now.

@Skyaero42
Copy link
Author

Working on it :)

@Skyaero42 Skyaero42 force-pushed the skyaero/remove-redundant-include-guards branch from d1c75bb to d630325 Compare October 23, 2025 19:32
@Skyaero42 Skyaero42 marked this pull request as ready for review October 23, 2025 20:55
@Skyaero42
Copy link
Author

Ready for review

Copy link

Choose a reason for hiding this comment

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

This file contains:

#ifndef _BASE_TYPE_H_
#include <Lib/BaseType.h>
#endif


#ifndef HLOD_H
#define HLOD_H

#ifndef ANIMOBJ_H
Copy link

Choose a reason for hiding this comment

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

There are still things to clean in this file.

Also in

  • curve.h
  • uarray.h
  • colmath.h
  • registry.h
  • ...

and many more. I think you need to audit WW headers and remove all #ifndef around includes.

Or do you want to do that in a follow up change?

Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

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

This change cannot be merged as is with Rebasing, because it contains commits that do not compile on their own.

Will be merged with Squash, unless individual commits are fixed for Rebasing.

@xezon xezon added this to the Code foundation build up milestone Oct 24, 2025
@xezon xezon added the Approved Pull Request was approved label Oct 24, 2025
@Skyaero42
Copy link
Author

Let's squash merge this. I'll pick up the other ifdefs in a seperate PR. That allows this PR to focus on pragma once only

@xezon xezon changed the title refactor: remove redundant include guards after #pragma once refactor: Replace all header include guards with pragma once Oct 24, 2025
@xezon xezon merged commit 8a9db21 into TheSuperHackers:main Oct 24, 2025
19 checks passed
fbraz3 pushed a commit to fbraz3/GeneralsX that referenced this pull request Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved Pull Request was approved Refactor Edits the code with insignificant behavior changes, is never user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants