A yotta module to smooth over some of the differences between compilers.
Pack a structure, preventing any padding from being added between fields.
#include "compiler-polyfill/attributes.h"
struct foo{
char x;
int y;
} __packed;
Declare a type to be aligned on an N-byte boundary.
#include "compiler-polyfill/attributes.h"
struct bar{
int x;
} __align(16);
Declare a function argument to be unused, suppressing compiler warnings.
#include "compiler-polyfill/attributes.h"
void foo(int __unused arg){
}
Mark a function as being weak.
Note: weak functions are not friendly to making code re-usable, as they can only be overridden once (and if they are multiply overridden the linker will emit no warning). You should not normally use weak symbols as part of the API to re-usable yotta modules.
#include "compiler-polyfill/attributes.h"
void __weak foo() {
// a weak implementation of foo that can be overriden by a definition
// without __weak
}
Mark a function declaration as deprecated, if it used then a warning will be issued by the compiler.
#include "compiler-polyfill/attributes.h"
void foo(int arg) __deprecated;
Mark a function declaration as deprecated, if it used then a warning will be issued by the compiler possibly including the provided message. Note that not all compilers are able to display the message.
#include "compiler-polyfill/attributes.h"
void foo(int arg) __deprecated_message("don't foo any more, bar instead");