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

add explicit <unistd.h> include #209

Closed
wants to merge 1 commit into from
Closed

Conversation

rathann
Copy link
Contributor

@rathann rathann commented Nov 28, 2023

This fixes the following compilation error with Python 3.13.0a1:

c-ext/backend_c.c:275:13: error: implicit declaration of function ‘sysconf’; did you mean ‘sscanf’? [-Werror=implicit-function-declaration]
  275 |     count = sysconf(_SC_NPROCESSORS_ONLN);
      |             ^~~~~~~
      |             sscanf

According to https://docs.python.org/3.13/whatsnew/3.13.html:

Python.h no longer includes the <unistd.h> standard header file. If needed, it should now be included explicitly.
For example, it provides the functions: read(), write(), close(), isatty(), lseek(), getpid(), getcwd(), sysconf() and getpagesize(). As a consequence, _POSIX_SEMAPHORES and _POSIX_THREADS macros are no longer defined by Python.h. The HAVE_UNISTD_H and HAVE_PTHREAD_H macros defined by Python.h can be used to decide if <unistd.h> and <pthread.h> header files can be included.

See python/cpython#108783 .

This fixes the following compilation error with Python 3.13.0a1:
```
c-ext/backend_c.c:275:13: error: implicit declaration of function ‘sysconf’; did you mean ‘sscanf’? [-Werror=implicit-function-declaration]
  275 |     count = sysconf(_SC_NPROCESSORS_ONLN);
      |             ^~~~~~~
      |             sscanf
```

According to https://docs.python.org/3.13/whatsnew/3.13.html:

Python.h no longer includes the <unistd.h> standard header file.
If needed, it should now be included explicitly.
For example, it provides the functions: read(), write(), close(), isatty(), lseek(), getpid(), getcwd(), sysconf() and getpagesize().
As a consequence, _POSIX_SEMAPHORES and _POSIX_THREADS macros are no longer defined by Python.h.
The HAVE_UNISTD_H and HAVE_PTHREAD_H macros defined by Python.h can be used to decide if <unistd.h> and <pthread.h> header files can be included.

See python/cpython#108783 .
@indygreg
Copy link
Owner

unistd.h was added back into Python.h in python/cpython#112026. So this is no longer needed.

@indygreg indygreg closed this May 25, 2024
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

2 participants