99#include <pio.h>
1010#include <pio_internal.h>
1111
12+ #if defined __has_include
13+ #if __has_include (< execinfo .h > )
14+ #define PLATFORM_HAS_EXECINFO
15+ #endif /* __has_include (<execinfo.h>) */
16+ #endif /* __has_include */
17+
18+ #ifdef PLATFORM_HAS_EXECINFO
1219#include <execinfo.h>
20+ #endif /* PLATFORM_HAS_EXECINFO */
1321
1422/** This is used with text decomposition files. */
1523#define VERSNO 2001
@@ -522,6 +530,7 @@ pio_log(int severity, const char *fmt, ...)
522530void
523531print_trace (FILE * fp )
524532{
533+ #ifdef PLATFORM_HAS_EXECINFO
525534 void * array [10 ];
526535 size_t size ;
527536 char * * strings ;
@@ -540,6 +549,9 @@ print_trace(FILE *fp)
540549 fprintf (fp ,"%s\n" , strings [i ]);
541550
542551 free (strings );
552+ #else
553+ (void )fp ;
554+ #endif /* PLATFORM_HAS_EXECINFO */
543555}
544556
545557/**
@@ -1532,6 +1544,7 @@ pioc_write_nc_decomp_int(iosystem_desc_t *ios, const char *filename, int cmode,
15321544 strlen (my_order_str ) + 1 , my_order_str )))
15331545 return pio_err (ios , NULL , ret , __FILE__ , __LINE__ );
15341546
1547+ #ifdef PLATFORM_HAS_EXECINFO
15351548 /* Write an attribute with the stack trace. This can be helpful
15361549 * for debugging. */
15371550 void * bt [MAX_BACKTRACE ];
@@ -1562,6 +1575,7 @@ pioc_write_nc_decomp_int(iosystem_desc_t *ios, const char *filename, int cmode,
15621575 if ((ret = PIOc_put_att_text (ncid , NC_GLOBAL , DECOMP_BACKTRACE_ATT_NAME ,
15631576 strlen (full_bt ) + 1 , full_bt )))
15641577 return pio_err (ios , NULL , ret , __FILE__ , __LINE__ );
1578+ #endif /* PLATFORM_HAS_EXECINFO */
15651579
15661580 /* We need a dimension for the dimensions in the data. (Example:
15671581 * for 4D data we will need to store 4 dimension IDs.) */
0 commit comments