Skip to content

Commit

Permalink
Cryptlib: Include stddef.h in CrtLibSupport.h
Browse files Browse the repository at this point in the history
The changes in the openssl headers cause the inclusion of
CrtLibSupport.h eariler than the inclusion of stddef.h, so "offsetof"
was defined twice and this caused the followling build error:

In file included from Cryptlib/Include/openssl/buffer.h:23:0,
                 from Cryptlib/Include/openssl/x509.h:22,
                 from shim.c:56:
/usr/lib64/gcc/x86_64-suse-linux/6/include/stddef.h:417:0: error: "offsetof" redefined [-Werror]
 #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)

In file included from Cryptlib/Include/limits.h:15:0,
                 from Cryptlib/Include/openssl/ossl_typ.h:13,
                 from Cryptlib/Include/openssl/x509.h:20,
                 from shim.c:56:
Cryptlib/Include/CrtLibSupport.h:192:0: note: this is the location of the previous definition
 #define offsetof(type, member) ( (int) & ((type*)0) -> member )

We can lower the priority of the gcc include path or just remove the
path, but this might cause problem since the path was introduced on
purpose(*). Instead, including stddef.h first is more feasible.

(*) d51739a

Signed-off-by: Gary Lin <glin@suse.com>
  • Loading branch information
lcp authored and vathpela committed Aug 31, 2017
1 parent 1d39ada commit 1b5dbc4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Cryptlib/Include/OpenSslSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/MemoryAllocationLib.h>
#include <Library/DebugLib.h>

/*
* Include stddef.h to avoid redefining "offsetof"
*/
#include <stddef.h>

#define CONST const

//
Expand Down

0 comments on commit 1b5dbc4

Please sign in to comment.