part of shnell – a source to source compiler enhancement tool
© Jens Gustedt, 2019
Implement C2x’ new attribute syntax
This relies on legacy methods provided by common compilers such as gcc
’s __attribute__
.
You should provide your idea of the legacy compiler to use through the environment variable ATTRIBUTES
. This should provide the implementation specific prefix and is used to guess the implementation-specific syntax that implement attributes.
We currently support the following values:
gnu
is the GNU compilergcc
. It supports all current standard attributes as well as large number of implementation specific ones. The syntax is rewritten to something like__attribute__((tokens))
.clang
is treated a superset tognu
.std
is meant for compilers that don’t need rewriting, because they fully implement the attribute feature. Attribute tokens are rewritten to the form that has leading and trailing double underscores. Syntactically correct implementation-specific attributes are otherwise passed through. Other unknown attributes are removed.portability
is the same asstd
but all implementation-specific attributes are removed.gsl
is for the Microsoft compilers. The support the standard attributes but not much more. The resulting syntax is__declspec
.
Coding and configuration
The following code is needed to enable the sh-module framework.SRC="$_" . "${0%%/${0##*/}}/import.sh"
Imports
The following sh
-modules are imported: