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

Use fixed length data types in header, for portability #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gingerbeardman
Copy link

@gingerbeardman gingerbeardman commented May 6, 2020

Fixes #2

Problem

  • Old code assumes 4-byte (32-bit) long data type.
  • For me, on macOS with gcc or clang, long data type is 8-byte (64-bit).

Solution

  • So with regards to code that generates the bitmap header, I replace:
    • long with int32_t
    • unsigned long with u_int32_t
  • This results in correct output.

Working 64-bit macOS binary

Thanks for this utility!

@leovilok
Copy link

@gingerbeardman to use uint32_t you need to:

#include <stdint.h>

<sys/types.h> is already included, and it provides int32_t, but not uint32_t (provides u_int32_t instead). Tested on Linux + gcc 9.3.

@gingerbeardman
Copy link
Author

gingerbeardman commented May 11, 2020

@leovilok Thanks for that - much appreciated! I have changed the code to use u_int32_t as you suggested. Updated macOS binary at the link above.

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.

Generates invalid BMP on macOS
2 participants