Thursday 29 May 2008

GNU C extensions

GNU C has many extensions which make the programmer's life easier-... or not. But the resulting code is more efficient! One of these extensions is the compiler attribute preceding a function header specifying certain function behaviour. For example, a function can be forced to always be compiled inline with __attribute__((always_inline)). More than one attribute specifier can be used within the parentheses; full attribute syntax can be found here. Attributes can also specify the way the compiler treats types and variables.

Contiki employs attributes in its protothreading system (see core/sys/pt.h) for specifying return addresses via labels (core/sys/lc-addrlabels.h). The preferred alternative is a coroutine-based method (/core/sys/lc-switch.h) using switch-case control structures and the __LINE__ C macro.

No comments: