Skip to content

Commit dcba2e2

Browse files
Merge pull request #700 from ACSimon33/cblas_int64_warning_fix
Fixed format warnings in 64 bit integer builds.
2 parents cb8d38c + 0b5b0fa commit dcba2e2

File tree

9 files changed

+51
-11
lines changed

9 files changed

+51
-11
lines changed

CBLAS/examples/cblas_example1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ int main ( )
6161
y, incy );
6262
/* Print y */
6363
for( i = 0; i < n; i++ )
64-
printf(" y%d = %f\n", i, y[i]);
64+
printf(" y%" CBLAS_IFMT " = %f\n", i, y[i]);
6565
free(a);
6666
free(x);
6767
free(y);

CBLAS/include/cblas.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define CBLAS_H
33
#include <stddef.h>
44
#include <stdint.h>
5+
#include <inttypes.h>
56

67

78
#ifdef __cplusplus
@@ -24,6 +25,17 @@ extern "C" { /* Assume C declarations for C++ */
2425
#endif
2526
#endif
2627

28+
/*
29+
* Integer format string
30+
*/
31+
#ifndef CBLAS_IFMT
32+
#ifdef WeirdNEC
33+
#define CBLAS_IFMT PRId64
34+
#else
35+
#define CBLAS_IFMT PRId32
36+
#endif
37+
#endif
38+
2739
typedef enum CBLAS_LAYOUT {CblasRowMajor=101, CblasColMajor=102} CBLAS_LAYOUT;
2840
typedef enum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112, CblasConjTrans=113} CBLAS_TRANSPOSE;
2941
typedef enum CBLAS_UPLO {CblasUpper=121, CblasLower=122} CBLAS_UPLO;

CBLAS/src/cblas_xerbla.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ cblas_xerbla(CBLAS_INT info, const char *rout, const char *form, ...)
6363
}
6464
}
6565
if (info)
66-
fprintf(stderr, "Parameter %d to routine %s was incorrect\n", info, rout);
66+
fprintf(stderr, "Parameter %" CBLAS_IFMT " to routine %s was incorrect\n", info, rout);
6767
vfprintf(stderr, form, argptr);
6868
va_end(argptr);
6969
if (info && !info)

CBLAS/testing/c_xerbla.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void cblas_xerbla(CBLAS_INT info, const char *rout, const char *form, ...)
7878
}
7979

8080
if (info != cblas_info){
81-
printf("***** XERBLA WAS CALLED WITH INFO = %d INSTEAD OF %d in %s *******\n",info, cblas_info, rout);
81+
printf("***** XERBLA WAS CALLED WITH INFO = %" CBLAS_IFMT " INSTEAD OF %d in %s *******\n",info, cblas_info, rout);
8282
cblas_lerr = PASSED;
8383
cblas_ok = FALSE;
8484
} else cblas_lerr = FAILED;

LAPACKE/example/example_DGESV_colmajor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ int main(int argc, char **argv) {
9292
/* Check for the exact singularity */
9393
if( info > 0 ) {
9494
printf( "The diagonal element of the triangular factor of A,\n" );
95-
printf( "U(%i,%i) is zero, so that A is singular;\n", info, info );
95+
printf( "U(%" LAPACK_IFMT ",%" LAPACK_IFMT ") is zero, so that A is singular;\n", info, info );
9696
printf( "the solution could not be computed.\n" );
9797
exit( 1 );
9898
}

LAPACKE/example/example_DGESV_rowmajor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ int main(int argc, char **argv) {
8989
/* Check for the exact singularity */
9090
if( info > 0 ) {
9191
printf( "The diagonal element of the triangular factor of A,\n" );
92-
printf( "U(%i,%i) is zero, so that A is singular;\n", info, info );
92+
printf( "U(%" LAPACK_IFMT ",%" LAPACK_IFMT ") is zero, so that A is singular;\n", info, info );
9393
printf( "the solution could not be computed.\n" );
9494
exit( 1 );
9595
}

LAPACKE/example/lapacke_example_aux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ void print_matrix_colmajor( char* desc, lapack_int m, lapack_int n, double* mat,
2828
void print_vector( char* desc, lapack_int n, lapack_int* vec ) {
2929
lapack_int j;
3030
printf( "\n %s\n", desc );
31-
for( j = 0; j < n; j++ ) printf( " %6i", vec[j] );
31+
for( j = 0; j < n; j++ ) printf( " %6" LAPACK_IFMT, vec[j] );
3232
printf( "\n" );
3333
}

LAPACKE/include/lapack.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <stdlib.h>
1414
#include <stdarg.h>
15+
#include <inttypes.h>
1516

1617
/* It seems all current Fortran compilers put strlen at end.
1718
* Some historical compilers put strlen after the str argument
@@ -80,11 +81,26 @@ extern "C" {
8081

8182
/*----------------------------------------------------------------------------*/
8283
#ifndef lapack_int
83-
#define lapack_int int
84+
#if defined(LAPACK_ILP64)
85+
#define lapack_int int64_t
86+
#else
87+
#define lapack_int int32_t
88+
#endif
89+
#endif
90+
91+
/*
92+
* Integer format string
93+
*/
94+
#ifndef LAPACK_IFMT
95+
#if defined(LAPACK_ILP64)
96+
#define LAPACK_IFMT PRId64
97+
#else
98+
#define LAPACK_IFMT PRId32
99+
#endif
84100
#endif
85101

86102
#ifndef lapack_logical
87-
#define lapack_logical lapack_int
103+
#define lapack_logical lapack_int
88104
#endif
89105

90106
/* f2c, hence clapack and MacOS Accelerate, returns double instead of float

LAPACKE/include/lapacke_config.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,29 @@ extern "C" {
4242

4343
#include <stdlib.h>
4444
#include <stdint.h>
45+
#include <inttypes.h>
4546

4647
#ifndef lapack_int
4748
#if defined(LAPACK_ILP64)
48-
#define lapack_int int64_t
49+
#define lapack_int int64_t
4950
#else
50-
#define lapack_int int32_t
51+
#define lapack_int int32_t
52+
#endif
53+
#endif
54+
55+
/*
56+
* Integer format string
57+
*/
58+
#ifndef LAPACK_IFMT
59+
#if defined(LAPACK_ILP64)
60+
#define LAPACK_IFMT PRId64
61+
#else
62+
#define LAPACK_IFMT PRId32
5163
#endif
5264
#endif
5365

5466
#ifndef lapack_logical
55-
#define lapack_logical lapack_int
67+
#define lapack_logical lapack_int
5668
#endif
5769

5870
#ifndef LAPACK_COMPLEX_CUSTOM

0 commit comments

Comments
 (0)