Skip to content

ccan: fix compilation error about const types #6950

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

Conversation

vincenzopalazzo
Copy link
Collaborator

This commit fixes the following build error

ccan/ccan/fdpass/fdpass.c:16:8: error: variable length array folded to constant array as an extension [-Werror,-Wgnu-folding-constant] char buf[CMSG_SPACE(sizeof(fd))];

This is strange from a UNIX perspective because the macros return a size_t and the size_t is an unsigned integer type that should be compatible with the array declaration.

But for some plaform/or compilers this looks like not true?

Maybe Fixes #6910

This commit fixes the following build error

ccan/ccan/fdpass/fdpass.c:16:8: error: variable length array folded to
constant array as an extension [-Werror,-Wgnu-folding-constant] char
buf[CMSG_SPACE(sizeof(fd))];

This is strange from a UNIX proxpective because the macros
return a size_t and the size_t is a unsigned integer type that
should be compatible with the array declaration.

But for some plaform/or compiler this looks like not true?

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
@cdecker
Copy link
Member

cdecker commented Dec 22, 2023

I'd be truly surprised if moving preprocessor instructions around actually addresses a compilation error. As such I'd like to have confirmation that this addresses the issue at hand.

If this truly is a fix to the problem, then the patch also belongs upstreamed into ccan.

@vincenzopalazzo
Copy link
Collaborator Author

I'd be truly surprised if moving preprocessor instructions around actually addresses a compilation error. As such I'd like to have confirmation that this addresses the issue at hand.

Yeah, I am not able to take my mental model back, I forget why this could work. However, I am not able to work blinded so I just put this there and wait for a user that can help to track it down

If this truly is a fix to the problem, then the patch also belongs upstreamed into can.

Yep!

@vincenzopalazzo
Copy link
Collaborator Author

vincenzopalazzo commented Dec 23, 2023

Mh I was wrong, and @cdecker you are right my code is just another way to write the same things, looks like this is a GCC bug on osx?

libuv/libuv#454

@vincenzopalazzo vincenzopalazzo deleted the macros/compilation-issue branch December 23, 2023 11:16
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.

Build issue on x86_64-darwin
2 participants