Skip to content

Convert all cbool occurrences to Boolean #27

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

Merged
merged 1 commit into from
Jun 1, 2025

Conversation

suve
Copy link
Contributor

@suve suve commented May 28, 2025

Per discussion in #26, this PR replaces all occurrences of cbool with Boolean to fix struct size mismatch between C headers and our Pascal units.

On x86_64 Linux, FPC's ctypes.cbool type is 4 bytes in size, whereas
C99 _Bool and C23 bool types are 1 byte long. This causes mismatched
struct sizes and field alignments between C and Pascal code.

According to FPC developers, ctypes.cbool type is intended to replicate
the behaviour of using 'int' for storing boolean values in C code,
and not to be an equivalent of C99 _Bool / C23 bool. In the latter case,
plain Pascal Boolean is recommended.

See: https://gitlab.com/freepascal.org/fpc/source/-/issues/40746
Comment on lines +302 to +303
function SDL_SetBooleanProperty(props: TSDL_PropertiesID; name: PAnsiChar; value: Boolean): Boolean; cdecl;
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetBooleanProperty' {$ENDIF} {$ENDIF};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

An additional bugfix made along the way - the SDL_SetBooleanProperty function was named SDL_SecboolProperty in our code. Looks like a victim of a search & replace.

@Free-Pascal-meets-SDL-Website
Copy link
Contributor

Great, I would like to suggest (as done in #26 ) to use a different type name instead of Boolean directly (not introducing a new type). For some reason I can see that this could get handy in the future.

If you disagree with the idea, please don't hesitate to merge this PR :). I approve it.

@suve suve merged commit 076ac8e into PascalGameDevelopment:main Jun 1, 2025
@suve suve mentioned this pull request Jun 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants