Category Archives: GCC Extensions

Zero-length array to provide an elegant link

Posted in kerneltrap.org on May 18, 2008 – 10:22pm Consider the following struct and program: #include <stdio.h> #include <stdlib.h> struct fix_data { char data [5]; unsigned char optional_part [0]; } __attribute__ ((packed)); int main (int argc, char **argv, char **envp) … Continue reading

Posted in C, GCC Extensions, Hacking, Linux Kernel, Networking, Programming Languages, Software | Tagged | Leave a comment

Another way to use the C ternary operator (? :)

Posted in kerneltrap.org on May 12, 2008 – 7:58pm I found in Linux kernel 2.6.21.5 in include/net/netinet_hastables.h in function __inet_lookup this interesting expression: return sk ? : __inet_lookup_listener(hashinfo, daddr, hnum, dif); It turned out that it is actually okay if … Continue reading

Posted in C, GCC Extensions, Hacking, Linux Kernel, Programming Languages, Software | Tagged | Leave a comment