Linux API/linux2022. 10. 20. 10:50

커널이 5.4.0 이라 그런가

해당 선언을 해주어야 에러가 사라진다.

 

#define _GNU_SOURCE

[링크 : https://stackoverflow.com/questions/25411892/f-setpipe-sz-undeclared]

 

 

Defining _GNU_SOURCE has nothing to do with license and everything to do with writing (non-)portable code. If you define _GNU_SOURCE, you will get:
  1. access to lots of nonstandard GNU/Linux extension functions
  2. access to traditional functions which were omitted from the POSIX standard (often for good reason, such as being replaced with better alternatives, or being tied to particular legacy implementations)
  3. access to low-level functions that cannot be portable, but that you sometimes need for implementing system utilities like mount, ifconfig, etc.
  4. broken behavior for lots of POSIX-specified functions, where the GNU folks disagreed with the standards committee on how the functions should behave and decided to do their own thing.
As long as you're aware of these things, it should not be a problem to define _GNU_SOURCE, but you should avoid defining it and instead define _POSIX_C_SOURCE=200809L or _XOPEN_SOURCE=700 when possible to ensure that your programs are portable.
In particular, the things from _GNU_SOURCE that you should never use are #2 and #4 above.
 

[링크 : https://stackoverflow.com/questions/5582211/what-does-define-gnu-source-imply]

 

호환성 지정 매크로

[링크 : https://m.blog.naver.com/netiz21/150015716721]

 

#include <fcntl.h> 대신

#include <linux/fcntl.h> 하면 _GNU_SOURCE를 해주지 않아도 되긴 한데

다른데서 경고가 뜨니 알아서 써야 할 듯.

/usr/include/linux/fcntl.h:28:#define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7)
/usr/include/linux/fcntl.h:29:#define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8)

'Linux API > linux' 카테고리의 다른 글

iio(industrial io) 문서  (0) 2022.11.11
mkpipe 와 poll  (0) 2022.10.26
linux fifo  (0) 2022.10.18
SIGPIPE  (0) 2022.10.17
linux ipc 최대 데이터 길이  (0) 2022.10.11
Posted by 구차니