Skip to content

BLD: Do not set __STDC_VERSION__ to zero during build #27650

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

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

mtelka
Copy link
Contributor

@mtelka mtelka commented Oct 26, 2024

The __STDC_VERSION__ set to zero prevents successful build on at least one platform - OpenIndiana. In addiiton, zero is not a valid value for __STDC_VERSION__ and it is unclear why the setting was added.

Closes #25366.

@github-actions github-actions bot added the 36 - Build Build related PR label Oct 26, 2024
@mattip
Copy link
Member

mattip commented Oct 27, 2024

As mentioned in the comments to the issue

It may just be for warning suppression (e.g., https://stackoverflow.com/questions/24477228/stdc-version-not-defined-in-c11).

and indeed, forcing c90 with gcc on ubuntu 22.04 shows it is not defined:

$ echo | gcc -std=c11 -dM -E - | grep __STDC_VERSION__
#define __STDC_VERSION__ 201112L
$ echo | gcc -std=c99 -dM -E - | grep __STDC_VERSION__
#define __STDC_VERSION__ 199901L
$ echo | gcc -std=c90 -dM -E - | grep __STDC_VERSION__
$

We use it without checking existence in numpy/_core/src/common/npy_atomic.h, all the other uses (and in Cython-generated code) have #if defined() guard. Maybe we could defensively add a guard to npy_atomic.h as well, even though I think we require c99 or higher.

@mtelka
Copy link
Contributor Author

mtelka commented Oct 27, 2024

I think it is expected (and correct) that __STDC_VERSION__ is not (automatically) defined for -std=c90. If there is a warning or error issued with -std=c90 then either newer C standard is required to compile or there is a bug in a header. Either in system one, or in numpy.

Should I update this PR to add the defined() guard to the npy_atomic.h file? Or is somewhere specified that C99 (or newer) is needed?

@mattip
Copy link
Member

mattip commented Oct 27, 2024

Should I update this PR to add the defined() guard to the npy_atomic.h file?

That would be great, yes. All the other occurrences have one.

The __STDC_VERSION__ set to zero prevents successful build on at least
one platform - OpenIndiana.  In addiiton, zero is not a valid value for
__STDC_VERSION__ and it is unclear why the setting was added.

Closes numpy#25366.
@mtelka
Copy link
Contributor Author

mtelka commented Oct 28, 2024

Should I update this PR to add the defined() guard to the npy_atomic.h file?

That would be great, yes. All the other occurrences have one.

Done.

@mattip mattip merged commit 65d5b86 into numpy:main Oct 28, 2024
67 checks passed
@mattip
Copy link
Member

mattip commented Oct 28, 2024

Thanks @mtelka

@mtelka mtelka deleted the STDC_VERSION branch October 28, 2024 07:42
@charris charris added 09 - Backport-Candidate PRs tagged should be backported and removed 09 - Backport-Candidate PRs tagged should be backported labels Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
36 - Build Build related PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: error: 'llrint' has not been declared in '::'
3 participants