Issue
I have come across the following in existing macro in application makefile: __EXPORTED_HEADERS__
added to the cflags for gcc: CPPFLAGS+=-D__EXPORTED_HEADERS__
.
I did not find the macro itself used in the code.
I see it is used in the Linux kernel, though I dont exactly understand how it is used there.
What is it used for, and why would someone compile their code with this macro defined?
Thanks.
Solution
elixir saerch __EXPORTED_HEADERS__
-> https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/types.h#L9
There are kernel headers meant to be used from user space. And there are a lot of kernel headers meant to be used only inside the kernel.
What is it used for,
The __EXPORTED_HEADERS__
is used to protect against user-space source files including kernel headers not meant for user-space. In case that happens, a warning is displayed.
why would someone compile their code with this macro defined?
To silence the warning meant for user-space when compiling as kernel.
Answered By - KamilCuk Answer Checked By - David Goodson (WPSolving Volunteer)