why am I getting an implicit declaration of function 'ndo_get_stats' error?
ndo_get_stats
is a net_device_ops
function pointer. You have to call it through the netdev_ops
field of your net_device
.
Something like this would work:
stats = dev->netdev_ops->ndo_get_stats(dev);
net_device get_stats function, how to use?
This is not a function. Its the declaration of a function pointer get_stats
which points to a function which receives a pointer to the structure net_device
and returns a pointer to a structure of type net_device_stats
Here is one use case
struct net_device *dev;
struct net_device_stats *device;
device = get_stats(dev);
EDIT From your comments, I see you are using an older version of the kernel. IN later kernels , structure net_device
still resides in linux/netdevice.h
but there's no get_stats
function pointer. Its changed into ndo_get_stats
and it is now under another structure net_device_ops
So start using these new function pointers.
C warning: implicit declaration of function
For a start, I don't think it's a good idea to be giving common.h
to the compiler in the makefile:
@$(CC) $(C_FLAGS) -c sgbd_server.c common.h
This would be better as just:
@$(CC) $(C_FLAGS) -c sgbd_server.c
Header files are usually incorporated with just an #include
. You appear to be telling the compiler to try and compile common.h
as a standalone C file. That's one difference between the client and server compile commands and you should fix it.
The only other thing I can suggest is that you may not be getting the header files you think you're getting. Start by putting the line:
#error Urk! in common.h
at the top of your common.h
and ensure the build fails there.
If not, then that file is coming from somewhere else. You may also want to do the same thing with your sgbd_server.h
file as well.
Based on your edit:
I found some .ghc files sitting in my source folder. Since they are not cleaned by make clean, I deleted manually those files. Guess what? No warning. What are those files and why are they created?
These are, assuming ghc
was a typo and you meant gch
, pre-compiled headers generated by gcc
, at least in part to speed up the compilation process. Rather than having to process a header file many times during a build (once per source file that includes it), pre-compiling it once and using the pre-compiled version is a lot more efficient.
I think this was most likely cause by the fact that you included common.h
on your compiler command line when you did the server. By default, header files given directly to gcc
will be turned into pre-compiled header files and used in preference after that point. To test this, I created a qq.h
file and executed gcc qq.h
and out popped qq.h.gch
.
It's quite likely, given that deleting them solved your problem, that these files were somehow causing your issues (be that the presence of pre-compiled headers older than the real headers or something else entirely). There's a good chance that your compile line:
@$(CC) $(C_FLAGS) -c sgbd_server.c common.h
would first compile the server program, including the old precompiled header, then make a new precompiled header out of the newer header file.
That's probably why a change to common.h
had no (immediate) effect. You would have to make ; touch common.h ; make
to ensure the newer pre-compiled header file was used in the server program.
Whether you want to track it back to the root cause and get a proper explanation is a matter of taste - there's a school of thought that you should sometimes just record how you fixed it and not worry too much, lest you become entangled in the very nature of reality itself.
Not me of course, I'm the personality type that will attempt to track my problems back to the individual sub-atomic particle that caused it, but sometimes pragmatism requires me to let it go :-)
Implicit declaration of function (static library)
Because static libraries are only read by the linker at the linking stage (and the static library doesn't contain its functions signatures anyway). The compiler needs to know what this function is at the compile stage. So you need to include the header file providing your function's signature.
implicit declaration of function ‘write’; did you mean ‘fwrite’?
To access the Posix low level file interface such as open
, read
, write
and close
, you should include <unistd.h>
.
Note however that your program does not seem to require such low level interface, you might consider creating your output file using standard streams declared in <stdio.h>
, using fopen
, fputs
or fprintf
and fclose
.
warning : Implicit declaration error
But i have defined it in bloc.c.
You may have defined it, but you also have to declare it
Declaring said function in bloc.h
should fix it.
Implicit declaration of function ‘mknod’ but I have the headers included
As you can see that for declaration of mknod()
function to stay after preprocessing stage, one of three macros (__USE_MISC, __USE_BSD, __USE_XOPEN_EXTENDED)
should be defined. Otherwise, declaration of mknod() will be removed during preprocessing stage.
#if defined __USE_MISC || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
extern int mknod (const char *__path, __mode_t __mode, __dev_t __dev)
__THROW __nonnull ((1));
You can use compiler options: -std=gnu99 -D_GNU_SOURCE
or you can define these macros on your own and place them above header file inclusion.
Related Topics
Auto-Start Program at Login in Angstrom on Beagleboard
How to Use Schell Script to Read Element from a File, Do Some Calculation and Write Back
Bash - Ignore Hidden Files and Empty Source Directory When Copying
Ssl/Qsslsocket_Openssl.Cpp:1414: Error: Q_Ssl_Ctrl Was Not Declared in This Scope Error
Bus Error Opening and Mmap'Ing a File
How to Use If/Else Awk to Evaluate a File and Extract This Information
Arduino Upload Error "Stk500_Recv(): Programmer Is Not Responding" in Fedora
How to Compare The Size of Two Directories
Issue with Signal Handling, Interrupt Handling
Linux Grep/Sed Certain Lines - Space Removal
Cygwin Xwin Server Randomly Loses Connection
Is There Some Cases in Which Sigkill Will Not Work
How to Delay Pipe Netcat to Connect on First Input
Reading Microphone Data by Polling Using Alsa [Or V4L2]
Why Does 'Change_Protection' Hog CPU While Loading a Large Amount of Data into Ram