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

Fix missing header for size_t #39

Merged
merged 2 commits into from
Feb 22, 2024
Merged

Conversation

funbiscuit
Copy link
Contributor

Without this standard C header it doesn't compile with following error:

src\binn.h(259): error C2081: 'size_t': name in formal parameter list illegal

Library itself (binn.c) compiles normally because it includes other standard headers before binn.h so binn.h receives size_t definition. But if you include binn.h in some other C file (like in writing.c) and don't include other headers, it won't compile.
stddef.h is standard header so I think it should be okay to include that. All compilers should support it.

src/binn.h Outdated Show resolved Hide resolved
@kroggen
Copy link
Collaborator

kroggen commented Feb 21, 2024

I never needed this include
You can see the tests run fine without it
Is this happening in a specific platform?
Which compiler are you using?
In which OS?

@funbiscuit
Copy link
Contributor Author

In your tests you include a bunch of std headers before including binn.h.

Try to change order of includes in test_binn.c to this one:

#include "../src/binn.h"

#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <math.h>  /* for fabs */
#include <assert.h>

You'll get an error from issue (at least I checked now and error is present on latest master).
Adding extra include helps and this compiles:

#include <stddef.h>
#include "../src/binn.h"

#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <math.h>  /* for fabs */
#include <assert.h>

In my program I included just binn.h in some files where I didn't need any std headers and recieved this error. I use gcc 13.2.1 on latest Arch Linux (Manjaro), but this should be the same with all compilers.

@kroggen kroggen merged commit 4790cfe into liteserver:master Feb 22, 2024
1 check passed
@kroggen
Copy link
Collaborator

kroggen commented Feb 22, 2024

OK, Thanks!

@funbiscuit funbiscuit deleted the fix-compile branch February 22, 2024 06:08
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