Skip to content

A yotta module to smooth over some of the differences between compilers.

License

Notifications You must be signed in to change notification settings

ARMmbed/compiler-polyfill

Repository files navigation

compiler-polyfill

A yotta module to smooth over some of the differences between compilers.

API

Attributes

__packed

Pack a structure, preventing any padding from being added between fields.

#include "compiler-polyfill/attributes.h"

struct foo{
   char x;
   int y;
} __packed;
__align(N)

Declare a type to be aligned on an N-byte boundary.

#include "compiler-polyfill/attributes.h"

struct bar{
   int x;
} __align(16);
__unused

Declare a function argument to be unused, suppressing compiler warnings.

#include "compiler-polyfill/attributes.h"

void foo(int __unused arg){
    
}
__weak

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
}
__deprecated

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;
__deprecated_message("message string")

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");

About

A yotta module to smooth over some of the differences between compilers.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages