fix: resolve static local initializer compile error in serverfps.inc - #32
Merged
Conversation
`static Address pHostTimeFrame = Address_Null;` fails with error 008 (must be a constant expression; assumed zero) because the compiler can't fold the `Address_Null` enum constant when used as a static local initializer. Static locals already default-initialize to 0, which is the same value as Address_Null, so drop the explicit initializer. No behavior change.
There was a problem hiding this comment.
Pull request overview
This PR fixes a SourcePawn compilation error in the serverfps.inc helper include by removing an explicit static local initializer that the compiler rejects as a “constant expression,” while keeping the runtime semantics unchanged (the static still defaults to zero on first use).
Changes:
- Remove the explicit
Address_Nullinitializer from thestatic Address pHostTimeFramelocal inGetHostTimeFrame()to avoid constant-expression compilation failure.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
GetHostTimeFrame()inserverfps.incfails to compile:The compiler can't resolve the named enum constant
Address_Nullas a compile-time constant when it's used to initialize astaticlocal variable (unlikenull, which is a compiler-level literal and works fine forstatic Handleelsewhere in the same file).Fix
Remove the explicit initializer. SourcePawn
staticlocals default-initialize to 0 on first use, which is exactly the value ofAddress_Null, so the logic in the function is unaffected.