RafaGago/mini-async-log

negative numbers

funkyshoc opened this issue · 8 comments

Is it true that for logging negative numbers, that you need to cast your variable with a (i64)/etc?
Logging negative numbers by having to remember your variable type and therefore cast it correctly for all integer based variables could be very problematic (since many parts of my code use uint64_t and int64_t) Or is it just that the gcc 4.8 I'm running doesn't like some part of the code.

In your example code for example I get the following line of 2=4294966065 instead of 2=-1231:

00000000000.017025326 [err_] message 40, 1=true, 2=4294966065, 3=432.12, 4=param4, 5=0xffffffffffffffff

Sounds like a bug

OK FYI so far it is the only showstopper preventing me from using the code in my project. Everything else seems to work quite well.

I'll look at it this evening, but it seems easy to fix. It seems to affect only to "int" on x64.

In the meantime maybe defining MAL_NO_VARIABLE_INTEGER_WIDTH makes the bug go away.

Fixed. It was the printf format specifier that was wrong on linux x64. I replaced it by the macros on inttypes.h

e988066

Seems to work thanks much! It was a little bit unintuitive for my c++ app that had to include -D__STDC_FORMAT_MACROS to get it to compile so perhaps worth noting somewhere in the readme/etc.

This is because inttypes.h won't set those PRIi32/etc defines otherwise:

/* The ISO C99 standard specifies that these macros must only be
defined if explicitly requested. */
#if !defined __cplusplus || defined __STDC_FORMAT_MACROS

It worked as-is for me, but I'll add the macro to the file later so it doesn't need to be manually defined,

I added the definition

d57f420

Thanks for the feedback!