diff options
author | Werner Zeh <werner.zeh@siemens.com> | 2019-07-11 12:47:19 +0200 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2019-07-12 11:02:29 +0000 |
commit | ac14a40d0e17571ad3495d45216842044def289e (patch) | |
tree | ce6cf38ba6f7a217690f5e63c4f21e6439ab68e1 /util/sconfig | |
parent | 98d19572b175ad44a83614cdf2c57ed0ba94a733 (diff) |
util/sconfig: Fix compile error with older glibc-headers
In patch e29a6ac16a9f478fc00ce7cb83f3779954e3168d (util/sconfig: Add
commonlib/helpers.h) helpers.h has been added to the include-list.
In headers.h we have a definition for __unused:
On a host system environment where glibc-headers-2.12-1.212 is
installed, a file included by <sys/stat.h> called bits/stat.h have the
following content on line 105 and onwards:
long int __unused[3];
where the mentioned part is part of the structure called struct stat.
If we include commonlib/helpers.h _before_ <sys/stat.h>, the symbol for
__unused will be defined by the preprocessor to be
'__attribute__((unused))', therefore the above mentioned structure member
will be expanded by the preprocessor to be
'long int __attribute__((unused))[3];', which is not a valid C syntax
and therefore produces a compile error for sconfig tool.
To handle this case we need to make sure commonlib/helpers.h is included
_after_ <sys/stat.h>. As the needed part of stat.h (which is
struct stat) is only used in main.c it is safe to move the include from
sconfig.h directly into main.c while taking care of the order.
Change-Id: I9e6960a318d3dd999e1e9c1df326d67094f3b5ce
Signed-off-by: Werner Zeh <werner.zeh@siemens.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/34236
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'util/sconfig')
-rw-r--r-- | util/sconfig/main.c | 2 | ||||
-rw-r--r-- | util/sconfig/sconfig.h | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/util/sconfig/main.c b/util/sconfig/main.c index 385ced16ab..85e0d8ea7f 100644 --- a/util/sconfig/main.c +++ b/util/sconfig/main.c @@ -15,6 +15,8 @@ */ #include <ctype.h> +/* stat.h needs to be included before commonlib/helpers.h to avoid errors.*/ +#include <sys/stat.h> #include <commonlib/helpers.h> #include "sconfig.h" #include "sconfig.tab.h" diff --git a/util/sconfig/sconfig.h b/util/sconfig/sconfig.h index e6363dea83..eea2a14e40 100644 --- a/util/sconfig/sconfig.h +++ b/util/sconfig/sconfig.h @@ -18,7 +18,6 @@ #include <stdlib.h> #include <string.h> #include <sys/types.h> -#include <sys/stat.h> #include <unistd.h> #include <errno.h> |