Pritam said:
line 7: error: dereferencing pointer to incomplete type
1. #include<stdio.h>
2. #include<sys/stat.h>
3. #include<stdlib.h>
4. void execname() {
5. struct task_struct *my;
6. my = find_task_by_id(getpid());
7. printf("%s",my->comm); error: dereferencing pointer to incomplete
type
8.
9. }
10. int main()
11. {
12. execname();
13. }
what's wrong with it
It appears that you have no definition of struct task_struct in scope,
so the compiler has no idea where the comm member is.
Some tips:
1) Never post code with line numbers. That only makes it difficult for
people who would like to help you, since they must edit out that
extraneous garbage. Similarly, don't make code uncompilable by
appending test like "error: dereferencing pointer to incomplete type" to
lines. Make such things legal comments.
2) indent your code so it is readable. By including line numbers, you
already told us you don't want the compiler to read your code. By
refusing to indent your code you are telling us you don't want humans to
read it either.
3) Don't expect reasonable answers about non-standard functionality. By
including the non-standard <sys/stat.h> you will have caused many to
stop reading right there. You *do* have a C question, and by dressing
it in non-standard dress you may have shut yourself off from an answer.
You could have asked your question in a way that avoided any reference
to non-standard functionality.
4) When you do have a question about non-standard features, ask in
newsgroups where it is appropriate. When you do ask, try to provide
complete code. For example, the function getpid() is typically a POSIX
or UNIX function, suggesting the kinds of newsgroups where it will be
topical. However, the declaration for getpid() is typically found in
<unistd.h>, which you did not include. The find_task_* family are, as
far as I know, Linux kernel routines, which will not be topical outside
of Linux mailing lists. If you have some other platform with that
family, post appropriately. However, your question suggests that you
are trying to skip some important steps (like learning C) which you
ought not skip.