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

Avoid macro redefined warning #3861

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Avoid macro redefined warning #3861

wants to merge 1 commit into from

Conversation

catap
Copy link
Contributor

@catap catap commented Apr 2, 2024

We redefines some macros on FreeBSD and OpenBSD, and it trigers some warning which may lead to failure when -Werror is used.

We redefines some macros on FreeBSD and OpenBSD, and it trigers some
warning which may lead to failure when `-Werror` is used.
Comment on lines +30 to 33
#ifdef _XOPEN_VERSION
#undef _XOPEN_VERSION
#endif
#define _XOPEN_VERSION 0
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it would be better to keep original macro

Suggested change
#ifdef _XOPEN_VERSION
#undef _XOPEN_VERSION
#endif
#define _XOPEN_VERSION 0
#ifndef _XOPEN_VERSION
#define _XOPEN_VERSION 0
#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.

Not sure, because only part of constant are missed and all of them is switched of.

Let me ping @LeeTibbert as well.

@ekrich
Copy link
Member

ekrich commented Apr 2, 2024

I think there was a discussion about this and we concluded that it was getting ugly so this second approach on top was followed. Perhaps a better approach to using #undef and all this stuff on top is to create a macro to replace the following where needed:

#ifdef _PC_ALLOC_SIZE_MIN
    return _PC_ALLOC_SIZE_MIN;
#else
    return 0;
#endif

You know, when macros get bad make another :-)

@catap
Copy link
Contributor Author

catap commented Apr 2, 2024

Ok, I'll take care of this in different way.

But I'd like to finish CI for BSD platform before I move.

@catap catap marked this pull request as draft April 2, 2024 20:22
@LeeTibbert
Copy link
Contributor

@catap

re: Let me ping @LeeTibbert as well.

I have been offline for awhile and am about to go offline for another longish (weeks) while.
I'll take a look if I can before I go offline again.

My rapid "wet" reading is that section probably long predates me and has to do with
what is and is_not POSIX and what is intended to be allowed in SN posixlib.

I believe, but would have to re-ground myself, that XOPEN is a superset of POSIX and
that the original intent was that only POSIX and possibly XSI were allowed in posixlib.

Compiling with _XOPEN_VERSION macro defined enabled the compilation of "intended-to-be-excluded"
XOPEN functions, so it was #undef'd. I think the #undef was because we do not have absolute control
over the compiler flags passed in; a user could -D_XOPEN_VERSION.

TL;DR - in case events need action before I can do all my evidence collection & tracing.

I think the ugly but cleanest solution is to put explicit OS specific guards around the _XOPEN_VERSION
handling. Again, ugly but gives future devos a sporting chance of understanding the logic chain.

That is, have the existing section for linux, MacOS (Windows?) and a new section
which does the alternate define of this PR for FreeBSD, NetBSD, and known others as they
may apply.

I would end with a "Unsupported OS" #error pragma.

Each OS gets what they are happy with and what has been tested & shown to work.

@catap
Copy link
Contributor Author

catap commented Apr 19, 2024 via email

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.

None yet

4 participants