473,403 Members | 2,366 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,403 software developers and data experts.

Dereferencing pointer to incomplete type error.

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);

struct napi_struct *napi = &adapter->rx_ring[0].napi; /*
<<<<<<<<<<<the error is on this line */
/* some other function stuff */
}

struct adapter_struct is defined as:
#define adapter_struct e1000_adapter

which is defined as:
struct e1000_adapter {
/* other members */
struct e1000_rx_ring *rx_ring;
/* other members */
};

struct e1000_rx_ring {
struct e1000_adapter *adapter;
#ifdef CONFIG_E1000_NAPI
struct napi_struct napi;
#endif
/* other members */
};

For netdev_priv() either the macro or the inline function is used:

#define netdev_priv(x) x->priv

OR

static inline void *netdev_priv(struct net_device *dev)
{
return (char *)dev + ((sizeof(struct net_device)
+ NETDEV_ALIGN_CONST)
& ~NETDEV_ALIGN_CONST);
}

struct net_device
{
void *priv;
/* other data */
}

In the particular line "&adapter->rx_ring[0].napi", after macro
substitution, dereferencing is not done in correct way, but I am not
able to figure out exactly where and how. I have tried casting the
void * part to particular struct type but, even that doesn't eliminate
the problem.
I think I have already provided all info related, if anything is
missing please point out.

I have looked for the problem around on net, couldn't find same thing,
so if this question is asked elsewhere please point to the same and I
apologize for adding the noise.
I think that problem is more of typical C compilation problem, so I
have assumed that this community is most relevant for asking this
question.
I apologize if I have unknowingly violated any community rule.

Thanks

Regards
Anuz
Nov 17 '08 #1
5 9448
On Nov 17, 10:19 am, Richard Heathfield <r...@see.sig.invalidwrote:
Anuz said:
Hi all,
While compiling a driver, I am getting this error:
error: dereferencing pointer to incomplete type

This normally means that you've got some kind of structure type for which a
declaration is visible (e.g. struct foo;) but not a definition. Perhaps
you've omitted a header or something like that.
int __kc_adapter_clean(struct net_device *netdev, int *budget)
{
/*some initialization stuff */
struct adapter_struct *adapter = netdev_priv(netdev);
struct napi_struct *napi = &adapter->rx_ring[0].napi; /*
<<<<<<<<<<<the error is on this line */

The adapter object is of type struct adapter_struct. Make sure you have a
definition of this struct type in scope. If it is your own type, this
shouldn't be hard. If it's a platform-specific structure, check your
documentation to discover which header you need.

Assuming that's all fine, look up the type of its rx_ring member, and go
through the same deal again.
/* some other function stuff */
}
All these structures are locally defined in a single header, which is
included in very first line, so that should not be the problem.

struct adapter_struct is defined as:
#define adapter_struct e1000_adapter

You'd be better off with:

typedef e1000_adapter adapter_struct;

but I'm puzzled as to what you think the synonym offers you.


Sorry, I have skipped the following:

#ifdef DRIVER_E1000
#define adapter_struct e1000_adapter
#endif

so this is used only if particular macro is defined.

Thanks
Anuz

Nov 17 '08 #2
Anuz wrote:
Sorry, I have skipped the following:

#ifdef DRIVER_E1000
#define adapter_struct e1000_adapter
#endif

so this is used only if particular macro is defined.
The obvious guess would be that 'DRIVER_E1000' macro is not defined,
which in turn disables the definition of 'adapter_struct' macro. The
rest follows.

--
Best regards,
Andrey Tarasevich
Nov 17 '08 #3
Anuz wrote:
>
The header is included in the very first line, which contains all the
definitions of the relevant structures. And all macros like
DRIVER_E1000 are all defined my Makefile itself.
Well, I'd re-verify that. Add an obvious error next to the definition of
'adapter_struct' macro and see whether the compiler catches it

#ifdef DRIVER_E1000
#define adapter_struct e1000_adapter
jasbdxjkasbcfjda /* just to make the compiler complain */
#endif

If it doesn't, then 'DRIVER_E1000' is _not_ defined.
I suspect that when at this line:
struct adapter_struct *adapter = netdev_priv(netdev);

it becomes:
adapter = netdev->priv;/* this is a (void *) data type */
What "is a (void *) data type"? netdev->priv? If so, it doesn't really
matter, since 'adapter' is not a 'void*'.
now when
struct napi_struct *napi = &adapter->rx_ring[0].napi;
this becomes
napi = &netdev->priv->rx_ring[0].napi; /* priv is (void *) data type
*/
No, things don't "become" like that in C. 'adapter' is not a macro, so
it doesn't just get substituted they way you seem to suggest.

--
Best regards,
Andrey Tarasevich
Nov 17 '08 #4
Andrey Tarasevich said:
Anuz wrote:
>>
The header is included in the very first line, which contains all the
definitions of the relevant structures. And all macros like
DRIVER_E1000 are all defined my Makefile itself.

Well, I'd re-verify that. Add an obvious error next to the definition of
'adapter_struct' macro and see whether the compiler catches it

#ifdef DRIVER_E1000
#define adapter_struct e1000_adapter
jasbdxjkasbcfjda /* just to make the compiler complain */
#endif

If it doesn't, then 'DRIVER_E1000' is _not_ defined.
Slightly more elegantly:

#ifdef DRIVER_E1000
#define adapter_struct e1000_adapter
#error DRIVER_E1000 is defined - now remove this error message
#endif

Note, too, that the OP should be using typedef, not #define, for type
synonyms.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Nov 17 '08 #5

On Nov 17, 12:23 pm, Andrey Tarasevich <andreytarasev...@hotmail.com>
wrote:
Anuz wrote:
The header is included in the very first line, which contains all the
definitions of the relevant structures. And all macros like
DRIVER_E1000 are all defined my Makefile itself.

Well, I'd re-verify that. Add an obvious error next to the definition of
'adapter_struct' macro and see whether the compiler catches it

#ifdef DRIVER_E1000
#define adapter_struct e1000_adapter
jasbdxjkasbcfjda /* just to make the compiler complain */
#endif

If it doesn't, then 'DRIVER_E1000' is _not_ defined.
I suspect that when at this line:
struct adapter_struct *adapter = netdev_priv(netdev);
it becomes:
adapter = netdev->priv;/* this is a (void *) data type */

What "is a (void *) data type"? netdev->priv? If so, it doesn't really
matter, since 'adapter' is not a 'void*'.
now when
struct napi_struct *napi = &adapter->rx_ring[0].napi;
this becomes
napi = &netdev->priv->rx_ring[0].napi; /* priv is (void *) data type
*/

No, things don't "become" like that in C. 'adapter' is not a macro, so
it doesn't just get substituted they way you seem to suggest.
"become" is the wrong word, my mistake.
Yes, right, E1000_DRIVER is not defined, I have tried using #error.

Thanks a loads.

Regards
Anuz
Nov 17 '08 #6

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

Similar topics

6
by: Pushkar Pradhan | last post by:
I tried to read the archives and solve this problem, but now I think I better post my problem: int main() { int blkSz = { {2,2}, {2,3}, ....., {6,6} }; write_bc_perf(mflops1, blkSz,...
22
by: Neo | last post by:
Hi Folks, #include<stdio.h> int main() { int (*p); int arr; int i;
204
by: Alexei A. Frounze | last post by:
Hi all, I have a question regarding the gcc behavior (gcc version 3.3.4). On the following test program it emits a warning: #include <stdio.h> int aInt2 = {0,1,2,4,9,16}; int aInt3 =...
5
by: Steven | last post by:
Hello, I get the following message during compilation: `dereferencing pointer to incomplete type' It stems from the compare function I use with qsort() and I am not quite sure how to fix it....
8
by: friend.05 | last post by:
I have three files. graph.h: My header file where I have typedef for my structure and function delcaration typedef struct _ipc_actors ipc_graph_actors; typedef ipc_graph_type...
4
by: Pritam | last post by:
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 =...
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),...
6
by: hnshashi | last post by:
I have written kernel(2.4) module to communicate with user application using "Netlink Socket". I am getting compilation error "Dereferencing pointer to incomplete type" in kernel module for "nlh...
50
by: Juha Nieminen | last post by:
I asked a long time ago in this group how to make a smart pointer which works with incomplete types. I got this answer (only relevant parts included): ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.