473,803 Members | 2,913 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5237
On Jun 7, 12:03 am, Pritam <chh...@gmail.c omwrote:
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.c omwrote:
>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.c omwrote:
>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.securityfoc us.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
6701
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 assert could be used to start an interactive debugger automatically. How do I realize that on a Linux machine using gcc?
4
16164
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 to pass both as "void *buf" so that it can accept any data type. But since I access the buffer and try to assign its elements to another I get compile errors (I have pasted at the end). Now my question is how can I pass the i/p and o/p buffers...
7
2197
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 message2 = {"\nCurved portion of graph -- R.A.C.\ \n A D E"};
4
1344
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 with three '***'. #include "palmvector.h" struct palmvectornode{ char ch;
7
51149
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
2971
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 newsgroup suggests that the error arises when the proper header files are missing, but when the header file I've got is sufficient to compile one instance of the call, but not the other, I don't know where to turn next.
5
3191
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), "ctx->statemachine != NULL", TRUE); backend_sm_check_globals(check);
5
1200
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* message; .... }
5
9486
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 initialization stuff */ struct adapter_struct *adapter = netdev_priv(netdev);
0
9703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10555
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10317
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10300
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9127
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2974
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.