error: field has incomplete type
Hello there,
Here is how it goes - I have written a small test driver as an exercise to "Linux Device Drivers" and as a preparation for writing a real, functional driver. For the sake of seeing how far I got it working (I already implemented the open(0, read(), write() and ioctl() calls) I wrote a simple programm which queries some information from the driver: Code:
#include <stdio.h> Code:
~/src/rwtest # make Code:
struct iptimer_dev{ As far as the compilation of the driver itself, everithing goes well. Here's a link to the actual driver source code, which I wrote. Any suggestions are welcome. :) _______________________________ Code:
07-08-09 12:41 :( # uname -a |
OK, I found out what my stupid mistake was - I try to include the header file of the driver in a user space program, and while compiling the driver with -D__KERNEL__ goes fine, the user space doesn't recognize the definitions wrapped inside the #define __KERNEL__ macro.
So, hope that will help someone, someday... :) |
Hello:
I am also getting same error.. can you please explain me in detail?? please........... Thanks |
It really links using that? I can imagine it would compile, but I don't know how the kernel symbols are resolved at link time unless you aren't actually using any kernel code other than struct iptimer_dev. It doesn't look like you do, but I'd think that there would also be a user-space include for the macros.
ta0kira |
I think the problem (at least the original problem) was that while the declaration of struct iptimer_dev was in the userspace namespace (i.e., visible without defining __KERNEL__), some of the types of its elements (namely struct cdev and struct semaphore ) had complete declarations visible only with __KERNEL__. Thus, the overall type struct iptimer_dev was “incomplete” (which means, among other things that you can’t compute its size, but you can have pointers to it, etc.).
So the moral of the story is that if you write a header file to be used in both userspace and kernelspace, armor the sections which you absolutely know that userspace will not need access to with “#ifdef __KERNEL__” and “#endif” to protect them from being visible. I wonder how this affects naresh5677 (who was scarce on details) or why you are reviving a 6-month-old thread. |
All times are GMT -5. The time now is 02:35 PM. |