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

Future-proofing for CUnit-derived class sizing #1888

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sprunk
Copy link
Collaborator

@sprunk sprunk commented Jan 10, 2025

Extracted from @saurtron's code and modified a bit.

@sprunk sprunk requested a review from saurtron January 10, 2025 23:47
@@ -7,11 +7,15 @@
#include "Sim/Misc/GlobalConstants.h"
#include "System/MemPoolTypes.h"

/* Size asserted manually in UnitHandler.cpp (to avoid extra #includes here).
* TODO: would be good if this could be found automatically via metaprogramming */
using LargestDerivedFromCUnit = CBuilder;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This will be the only line that needs changing in the future if a different type becomes larger.

@saurtron
Copy link
Collaborator

I think it can be done like this:

union LargestDerivedFromCUnit
{
        CUnit unit;
        CBuilder builder;
        CFactory factory;
        CBuilding building;
        CExtractorBuilding extractorBuilding;
};

@sprunk sprunk force-pushed the largest-derived-from-cunit branch from e2a584c to ed18f16 Compare January 12, 2025 01:54
@saurtron saurtron added the status: candidate PRs that should be good to go or important for next release label Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: candidate PRs that should be good to go or important for next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants