Correct usage printf with 64 bit numbers

Signed-off-by: Shahbaz Youssefi <shabbyx@gmail.com>
pull/19/head
Shahbaz Yousefi 2015-12-01 17:50:15 -05:00 committed by Shahbaz Youssefi
parent a7358b19d7
commit d54054f38e
2 changed files with 6 additions and 4 deletions

View File

@ -13,6 +13,7 @@
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include "ethercattype.h"
#include "nicdrv.h"
@ -155,7 +156,7 @@ char* SDO2string(uint16 slave, uint16 index, uint8 subidx, uint16 dtype)
break;
case ECT_INTEGER64:
i64 = (int64*) &usdo[0];
sprintf(hstr, "0x%16.16llx %lld", *i64, *i64);
sprintf(hstr, "0x%16.16"PRIx64" %"PRId64, *i64, *i64);
break;
case ECT_UNSIGNED8:
u8 = (uint8*) &usdo[0];
@ -172,7 +173,7 @@ char* SDO2string(uint16 slave, uint16 index, uint8 subidx, uint16 dtype)
break;
case ECT_UNSIGNED64:
u64 = (uint64*) &usdo[0];
sprintf(hstr, "0x%16.16llx %llu", *u64, *u64);
sprintf(hstr, "0x%16.16"PRIx64" %"PRIu64, *u64, *u64);
break;
case ECT_REAL32:
sr = (float*) &usdo[0];

View File

@ -13,6 +13,7 @@
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include "ethercattype.h"
#include "nicdrv.h"
@ -155,7 +156,7 @@ char* SDO2string(uint16 slave, uint16 index, uint8 subidx, uint16 dtype)
break;
case ECT_INTEGER64:
i64 = (int64*) &usdo[0];
sprintf(hstr, "0x%16.16llx %lld", *i64, *i64);
sprintf(hstr, "0x%16.16"PRIx64" %"PRId64, *i64, *i64);
break;
case ECT_UNSIGNED8:
u8 = (uint8*) &usdo[0];
@ -172,7 +173,7 @@ char* SDO2string(uint16 slave, uint16 index, uint8 subidx, uint16 dtype)
break;
case ECT_UNSIGNED64:
u64 = (uint64*) &usdo[0];
sprintf(hstr, "0x%16.16llx %llu", *u64, *u64);
sprintf(hstr, "0x%16.16"PRIx64" %"PRIu64, *u64, *u64);
break;
case ECT_REAL32:
sr = (float*) &usdo[0];