472,965 Members | 2,430 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,965 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 5185
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.