mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
xen: Use auto keyword as per C23
In macros it is common to declare local variables using typeof(param) in order to ensure that side effects are only evaluated once. A consequence of this is double textural expansion of the parameter, which can get out of hand very quickly with nested macros. In C23, the auto keyword has been repurposed to perform type inference. A GCC extension, __auto_type, is now available in the new toolchain baseline and avoids the double textural expansion. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Nicola Vetrini <nicola.vetrini@bugseng.com> Reviewed-by: Frediano Ziglio <frediano.ziglio@cloud.com>
This commit is contained in:
1 parent
69e8aaf9cc
commit
6238c97ea4
6 files changed
+42
-9
No files matched your search
@@ -129,6 +129,11 @@ Fixed width types should only be used when a fixed width quantity is
|
||||
meant (which for example may be a value read from or to be written to a
|
||||
register).
|
||||
|
||||
Macros which otherwise would use "typeof(arg) newarg =" to avoid double
|
||||
evaluation of side effects should use "auto newarg =" per it's C23 behaviour,
|
||||
to also avoid double textural expansion. The use of "auto" outside of macros
|
||||
is discouraged.
|
||||
|
||||
Especially with pointer types, whenever the pointed to object is not
|
||||
(supposed to be) modified, qualify the pointed to type with "const".
|
||||
|
||||
|
||||