473,322 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

get processs name; error: dereferencing pointer to incomplete type

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

Jun 7 '07 #1
4 5208
On Jun 7, 12:03 am, Pritam <chh...@gmail.comwrote:
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
You haven't included whatever header(s) you need to define the
structure type task_struct. This structure isn't defined by the C
standard, so you need to look in the documentation for programming on
whatever OS you are using, or ask in a newsgroup which discusses
programming on that OS.

Jun 7 '07 #2
On Thu, 07 Jun 2007 07:03:08 -0000, Pritam <ch****@gmail.comwrote:
>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;
The standard guarantees that all pointers to struct have the same
representation. Therefore, the compiler knows everything it needs to
reserve the correct amount of space with the correct alignment for the
object my. But at this point, the only thing the compiler knows about
struct task_struct is that it is a structure.
>6. my = find_task_by_id(getpid());
Presumably the function is declared in one of your non-standard
headers and returns either a void* or a struct task_struct*. If this
is the case, the compiler has enough information to generate the
correct code for this statement. If it is not the case, you have
omitted at least one mandatory diagnostic.
>7. printf("%s",my->comm); error: dereferencing pointer to incomplete
type
However, at this point, the compiler needs to know the internal
structure of the object pointed to by my. Is there a member named
comm? Is it a char*? Where in the structure is it located? You have
failed to provide these details so the compiler's knowledge of the
type struct task_struct is incomplete.
>8.
9. }
10. int main()
11. {
12. execname();
13. }


Remove del for email
Jun 7 '07 #3
"J. J. Farrell" wrote:
On Jun 7, 12:03 am, Pritam <chh...@gmail.comwrote:
>line 7: error: dereferencing pointer to incomplete type

1. #include<stdio.h>
2. #include<sys/stat.h>
Unknown include file - not part of the C standard.
>3. #include<stdlib.h>
4. void execname() {
5. struct task_struct *my;
Undefined type.
>6. my = find_task_by_id(getpid());
Undefined routine.
>7. printf("%s",my->comm); error: deref ptr to incomplete type
Ignoring the "comment", my->comm undefined.
>8.
9. }
10. int main()
int main(void) is better.
>11. {
12. execname();
Failure to return a value.
>13. }

what's wrong with it

You haven't included whatever header(s) you need to define the
structure type task_struct. This structure isn't defined by the C
standard, so you need to look in the documentation for programming on
whatever OS you are using, or ask in a newsgroup which discusses
programming on that OS.
Above is a fairly detailed list. I may have missed something.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jun 7 '07 #4
Pritam wrote:
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.hyou 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.

Jun 7 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Christian Christmann | last post by:
Hi, assert and error handling can be used for similar purposes. When should one use assert instead of try/catch and in which cases the error handling is preferable? I've read somewhere that...
4
by: Pushkar Pradhan | last post by:
I have some functions which take as i/p a buffer (it can be float, char, or 16 bit, int etc.). The result is another o/p buffer, its type is also flexible (it could be a float, char etc.). I try...
7
by: Jacob Schmidt | last post by:
Could anyone correct the error in my logic here?: #include <stdio.h> #include <stdlib.h> main () { const char message1 = {"\nCurved portion of graph -- D.G.A.C.\ \n A B C"}; const char...
4
by: cpptutor2000 | last post by:
I am trying to create a simple linked list. The source code is provided below. I receive the following error message: (Please see after source code). I have marked the lines where the error occurs...
7
by: Vivi | last post by:
Hello everybody, I'm writing a game program, and i have compilations errors.. :confused: typedef struct { struct lieu* cont; struct joueur* j;
5
by: Charles Packer | last post by:
In the code example below, why does the reference to gdk_pixbuf_new_from_file in main compile okay, but in subr2 gives the error "dereferencing pointer to incomplete type"? A search through this...
5
by: tejesh | last post by:
I am trying to compile the following code int backend_sm_run(struct interface_data *ctx) { xsup_assert((ctx != NULL), "ctx != NULL", TRUE); xsup_assert((ctx->statemachine != NULL),...
5
by: Alexander Mahone | last post by:
OK, I have this piece of code: void method(void* parameter) { 1: struct Data* dataOfReference=(struct Data*)parameter; 2: Info tmpInfo=(*dataOfReference).payload.data; 3: char*...
5
by: Anuz | last post by:
Hi all, While compiling a driver, I am getting this error: error: dereferencing pointer to incomplete type int __kc_adapter_clean(struct net_device *netdev, int *budget) { /*some...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.