mirror of
https://github.com/TREX-CoE/trexio.git
synced 2024-12-22 12:23:54 +01:00
include inttypes to fix portability issues in text back end
This commit is contained in:
parent
57655a8344
commit
20d551a70b
@ -40,7 +40,7 @@ AC_PROG_CC_C99
|
||||
# Checks for basic libraries.
|
||||
AC_CHECK_LIB([m], [sqrt])
|
||||
# Checks for basic header files.
|
||||
AC_CHECK_HEADERS([fcntl.h stdint.h stdlib.h string.h unistd.h])
|
||||
AC_CHECK_HEADERS([fcntl.h inttypes.h stdint.h stdlib.h string.h unistd.h])
|
||||
|
||||
# Search for pthread
|
||||
have_pthreads=no
|
||||
@ -154,8 +154,8 @@ AC_CHECK_FUNCS([memset mkdir strerror])
|
||||
|
||||
AC_CONFIG_FILES([Makefile
|
||||
src/Makefile
|
||||
trexio.pc
|
||||
tests/Makefile])
|
||||
tests/Makefile
|
||||
trexio.pc])
|
||||
AC_OUTPUT
|
||||
|
||||
echo \
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include "trexio_private.h"
|
||||
#include "trexio_s.h"
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -347,7 +347,7 @@ trexio_text_read_$group$ (trexio_text_t* const file)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rc = fscanf(f, "%lu\n", &($group$->dims_$group_dset$[i]));
|
||||
rc = fscanf(f, "%" SCNu64 "\n", &($group$->dims_$group_dset$[i]));
|
||||
assert(!(rc != 1));
|
||||
if (rc != 1) {
|
||||
FREE(buffer);
|
||||
@ -373,7 +373,7 @@ trexio_text_read_$group$ (trexio_text_t* const file)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rc = fscanf(f, "%lu", &($group$->$group_num$));
|
||||
rc = fscanf(f, "%" SCNu64 "", &($group$->$group_num$));
|
||||
assert(!(rc != 1));
|
||||
if (rc != 1) {
|
||||
FREE(buffer);
|
||||
@ -479,14 +479,14 @@ trexio_text_flush_$group$ (trexio_text_t* const file)
|
||||
if ($group$->rank_$group_dset$ != 0) size_$group_dset$ = 1;
|
||||
|
||||
for (unsigned int i=0; i<$group$->rank_$group_dset$; ++i){
|
||||
fprintf(f, "dims_$group_dset$ %u %lu\n", i, $group$->dims_$group_dset$[i]);
|
||||
fprintf(f, "dims_$group_dset$ %u %" PRIu64 "\n", i, $group$->dims_$group_dset$[i]);
|
||||
size_$group_dset$ *= $group$->dims_$group_dset$[i];
|
||||
}
|
||||
|
||||
// END REPEAT GROUP_DSET
|
||||
|
||||
// START REPEAT GROUP_NUM
|
||||
fprintf(f, "$group_num$ %lu\n", $group$->$group_num$);
|
||||
fprintf(f, "$group_num$ %" PRIu64 "\n", $group$->$group_num$);
|
||||
// END REPEAT GROUP_NUM
|
||||
|
||||
/* Write arrays */
|
||||
@ -758,7 +758,7 @@ rdm_t* trexio_text_read_rdm(trexio_text_t* const file) {
|
||||
assert (rc == 1);
|
||||
assert (strcmp(buffer, "dim_one_e") == 0);
|
||||
|
||||
rc = fscanf(f, "%lu", &(rdm->dim_one_e));
|
||||
rc = fscanf(f, "%" SCNu64 "", &(rdm->dim_one_e));
|
||||
assert (rc == 1);
|
||||
|
||||
/* Allocate arrays */
|
||||
@ -831,7 +831,7 @@ trexio_exit_code trexio_text_flush_rdm(trexio_text_t* const file) {
|
||||
fseek(f, 0L, SEEK_SET);
|
||||
|
||||
/* Write the dimensioning variables */
|
||||
fprintf(f, "num %lu\n", rdm->dim_one_e);
|
||||
fprintf(f, "num %" PRIu64 "\n", rdm->dim_one_e);
|
||||
|
||||
/* Write arrays */
|
||||
fprintf(f, "one_e\n");
|
||||
|
@ -151,8 +151,8 @@ for fname in files_funcs_groups:
|
||||
std_dtype_out = '24.16e'
|
||||
std_dtype_in = 'lf'
|
||||
elif params['dtype'] == 'int64_t':
|
||||
std_dtype_out = 'ld'
|
||||
std_dtype_in = 'ld'
|
||||
std_dtype_out = '" PRId64 "'
|
||||
std_dtype_in = '" SCNd64 "'
|
||||
|
||||
templine1 = templine2.replace('$group_dset_std_dtype_out$', std_dtype_out)
|
||||
templine2 = templine1.replace('$group_dset_std_dtype_in$', std_dtype_in)
|
||||
|
Loading…
Reference in New Issue
Block a user