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

There is no 32-bit WORD. That's called a DWORD #35

Open
danielmarschall opened this issue Aug 17, 2024 · 2 comments
Open

There is no 32-bit WORD. That's called a DWORD #35

danielmarschall opened this issue Aug 17, 2024 · 2 comments

Comments

@danielmarschall
Copy link

danielmarschall commented Aug 17, 2024

I noticed that I can't build sha256.c and sha256.h in Windows, because WORD is redefined with different data types.

There is no 32-bit WORD. A WORD is always 16-bit, and a DWORD would be 32-bit.

To fix this issue:

Change
typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines

To:
typedef unsigned long DWORD;

Then, change all WORD to DWORD in the code.


This does not only affect SHA256, but most of the other files too.

@danielmarschall
Copy link
Author

danielmarschall commented Aug 18, 2024

Actually, this is the correct definition. Now it also works on macOS:

#include <stdint.h>
typedef uint32_t DWORD;

@danielmarschall
Copy link
Author

Errata 2, now, after changing it to uint32_t, it compiles on MacOS, but now doesn't compile on Win32, because there is an incompatibility with LPDWORD*.

So, the correct and ONLY fix is to change sha256.h and sha256.c (and other files) to replace WORD with uint32_t. WORD and DWORD are reserved by the Microsoft API.

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

No branches or pull requests

1 participant