Skip to content

Commit

Permalink
Adding support for __STDC_FORMAT_MACROS to resolve a compilation issu…
Browse files Browse the repository at this point in the history
…e with include inttypes.h on older compilers (4.8.2) (#99)

Resolves: CryptoAlg-672

Description of changes:
On older systems supported by aws-c-cal, gcc 4.8.2, we run into compilation errors when building our test code. It turns out that some of the defines in inttypes are only defined if you specify __STDC_FORMAT_MACROS before including inttypes.h.

The change is very simple, add the __STDC_FORMAT_MACROS to each include to ensure it's always defined.
  • Loading branch information
darylmartin100 authored Feb 23, 2021
1 parent e50a2f3 commit 6566103
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crypto/bytestring/cbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
#include <openssl/bytestring.h>

#include <assert.h>

#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>

#include <string.h>

#include "internal.h"
Expand Down
4 changes: 4 additions & 0 deletions crypto/cpu-intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@

#if !defined(OPENSSL_NO_ASM) && (defined(OPENSSL_X86) || defined(OPENSSL_X86_64))

#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down
5 changes: 5 additions & 0 deletions crypto/err/err.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@

#include <assert.h>
#include <errno.h>

#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>

#include <string.h>

#if defined(OPENSSL_WINDOWS)
Expand Down
5 changes: 5 additions & 0 deletions crypto/fipsmodule/rand/fork_detect_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
// after multi-threaded fork is not supported".
#if defined(OPENSSL_LINUX) && !defined(OPENSSL_TSAN)
#include <errno.h>

#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>

#include <stdio.h>
#include <string.h>
#include <unistd.h>
Expand Down
4 changes: 4 additions & 0 deletions crypto/obj/obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@

#include <openssl/obj.h>

#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>

#include <limits.h>
#include <string.h>

Expand Down
4 changes: 4 additions & 0 deletions crypto/x509/a_strex.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@

#include <openssl/x509.h>

#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>

#include <string.h>

#include <openssl/asn1.h>
Expand Down
4 changes: 4 additions & 0 deletions include/openssl/bn.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@
#include <openssl/base.h>
#include <openssl/thread.h>

#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h> // for PRIu64 and friends

#include <stdio.h> // for FILE*

#if defined(__cplusplus)
Expand Down
5 changes: 5 additions & 0 deletions ssl/test/bssl_shim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ OPENSSL_MSVC_PRAGMA(comment(lib, "Ws2_32.lib"))
#endif

#include <assert.h>

#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>

#include <string.h>
#include <time.h>

Expand Down
3 changes: 3 additions & 0 deletions util/asm_dev/armv8/p256/src/beeu_scratch.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ The functions in this file were compiled into ARMv8 assembly code
in order to experiment with the generated instructions and use them in beeu.S.
*/

#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>

typedef double *__attribute__((aligned(64))) aligned_double;
Expand Down
3 changes: 3 additions & 0 deletions util/asm_dev/armv8/p256/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

#include <stdio.h>
#include <stdlib.h>
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>
#include "p256.h"

Expand Down

0 comments on commit 6566103

Please sign in to comment.