How to write documentation comments in ANSI C? [closed]
There are many different standards, if you want to generate documentation, try doxygen
There are many different standards, if you want to generate documentation, try doxygen
The simple answer is to use strtoul() instead. The longer answer is that even if all you needed was signed 32 bit integers or were happy with 31 bits for unsigned, the atoi() function is a poor fit for what you appear to be doing. As you have already noted, the atoi() function converts a … Read more
If you want the actual implementations, as everyone else has assumed you don’t, many Linux distributions currently use glibc to implement the C standard library. Common alternatives include musl libc, diet libc, uClibc, and Bionic
It’s something introduced in C99 which lets the compiler know that the pointer passed in there isn’t pointing to the same place as any other pointers in the arguments. If you give this hint to the compiler, it can do some more aggressive optimizations without breaking code. As an example, consider this function: int add(int … Read more
Move the typedef struct Preprocessor Prepro; to the header the file and the definition in the c file along with the Prepro_init definition. This is will forward declare it for you with no issues. Preprocessor.h #ifndef _PREPROCESSOR_H_ #define _PREPROCESSOR_H_ #define MAX_FILES 15 typedef struct Preprocessor Prepro; void Prepro_init(Prepro* p); #endif Preprocessor.c #include “Preprocessor.h” #include <stdio.h> … Read more
Many interfaces to the linux kernel are not well documented. Or even if they seem well documented, they can be pretty complex and that can make it hard to understanding what the functional or, often even harder, nonfunctional properties of the interface are. For this reason, my advice to anyone wanting a solid understanding of … Read more
Set a watch point on the counter: (gdb) watch var And make that watchpoint conditional: (gdb) cond <watchpoint_number> var>=value If you want to log to a file: (gdb) set logging file <filename> (gdb) set logging on By default gdb logs to gdb.txt
As said by others, only one signal handler can be set, which is the last one. You would then have to manage calling two functions yourself. The sigaction function can return the previously installed signal handler which you can call yourself. Something like this (untested code): /* other signal handlers */ static void (*lib1_sighandler)(int) = … Read more
You can bind to a specific interface by setting SO_BINDTODEVICE socket option. struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), “eth0”); if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, (void *)&ifr, sizeof(ifr)) < 0) { … error handling … } Warning: You have to be root or have the CAP_NET_RAW capability in order to use this option. The second … Read more
Accessing the performance counters isn’t difficult, but you have to enable them from kernel-mode. By default the counters are disabled. In a nutshell you have to execute the following two lines inside the kernel. Either as a loadable module or just adding the two lines somewhere in the board-init will do: /* enable user-mode access … Read more