简体   繁体   中英

When using makefile, linux header is found, but when functions from the header are called, it says they are implicitly declared

I'm writing a kernel module and I've begun to look into sockets. I've been able to include other linux headers, use their functions, and the makefile will be fine. When I include linux/socket.h, the compiler is able to find the file, but if I call socket() or connect() or such, it says they are implicitly declared. How would I be able to fix this?

I've used cat to look into the file to make sure it's correct, which it is. I've tried just hardcoding the location

/usr/src/linux-headers-4.18.0-17-generic/linux/socket.h

I've also tried using linux-headers-4.18.0-17's socket.h but that also doesn't work.

one of the errors: error: implicit declaration of function 'socket'; did you mean 'sget'? [-Werror=implicit-function--declaration]

Because it's not socket() , it's sys_socket() and you also need the header file containing the system calls. That one only contains structs and constants. The header file with the function itself is linux/syscalls.h .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM