[Click] #include <unistd.h> header in kernel ?

Cliff Frey clfrey at cisco.com
Sun Aug 25 20:23:58 EDT 2013


You cannot use unistd.h (or any other standard userlevel headers) in the
kernel.  Whatever you are trying to do must be done in a different way.
 Specifically you cannot use getpid().

What do you want/need getpid for?

Cliff


On Sun, Aug 25, 2013 at 1:35 PM, ndritsos <ndritsos at gmail.com> wrote:

> Hello everyone ,
>
> i have created an element that uses  the library unistd.h,  and in the
> user level it works fine .
> Now i'm working in kernel level , and it doesn't work.
>
> in kernel level i have imported :
>
> #include <linux/unistd.h>
>
> and i have this  compile time error:
> ---
> In file included from
> /home/dritsos/click/linuxmodule/../elements/local/ndritso.cc:23:0:
> /home/dritsos/click/include/click-linuxmodule/include2/linux/unistd.h:5:3:
> error: #error "missing #include <click/cxxprotect.h>"
> In file included from
> /home/dritsos/click/include/click-linuxmodule/include2/linux/unistd.h:12:0,
>                   from
> /home/dritsos/click/linuxmodule/../elements/local/ndritso.cc:23:
> /home/dritsos/click/include/click-linuxmodule/include0/asm/unistd.h:4:3:
> error: #error "missing #include <click/cxxprotect.h>"
> In file included from
> /home/dritsos/click/include/click-linuxmodule/include0/asm/unistd.h:8:0,
>                   from
> /home/dritsos/click/include/click-linuxmodule/include2/linux/unistd.h:12,
> from /home/dritsos/click/linuxmodule/../elements/local/ndritso.cc:23:
> /home/dritsos/click/include/click-linuxmodule/include0/asm/unistd_32.h:5:3:
> error: #error "missing #include <click/cxxprotect.h>"
> /home/dritsos/click/linuxmodule/../elements/local/ndritso.cc: In member
> function 'virtual int NdritsoElement::initialize(ErrorHandler*)':
> /home/dritsos/click/linuxmodule/../elements/local/ndritso.cc:59:8:
> error: 'getpid' was not declared in this scope
> make[3]: *** [/home/dritsos/click/linuxmodule/ndritso.o] Error 1
> make[2]: *** [_module_/home/dritsos/click/linuxmodule] Error 2
> make[2]: Leaving directory `/usr/src/linux-headers-3.0.0-12-generic'
> make[1]: *** [all] Error 2
> make[1]: Leaving directory `/home/dritsos/click/linuxmodule'
> make: *** [install-linuxmodule] Error 2
>
>
> ---
>
>
> Any idea how i can fix this error??
>
> thanks in advance
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>


More information about the click mailing list