On Thu, Jun 23, 2011 at 4:39 PM, Laurent Gauch
<laurent.ga...@amontec.com> wrote:
>> >/ On Thu, Jun 23, 2011 at 1:03 PM, Steve Bennett <steveb at
>> > workware.net.au
>> > <https://lists.berlios.de/mailman/listinfo/openocd-development>> wrote:
>> />>/ On 23/06/2011, at 8:59 PM, Øyvind Harboe wrote:
>> />>/ />>>/ I don't think this is sufficient, as it will put up warnings on
>> some
>> />>>/ other platforms unless you use the macros that expand to the
>> />>>/ correct formatting string.
>> />>>/ />>>/ See C99 section:
>> />>>/ />>>/ http://en.wikipedia.org/wiki/Printf
>> />>/ />>/ Can you provide an example of a platform which produces
>> warnings?
>> />>/ I don't see how.
>> />/ />/ I haven't followed this(big discussions), but I've seen on the
>> list
>> />/ in the past that casting is frowned upon and using these
>> />/ macros is cheered... Anyway... I'm happy to follow the path
>> />/ of using these macros, I certainly don't want to become an
>> />/ expert! :-)
>> /
>
> We do not ask maintainers, as you, to be experts.
>>
>> I guess I'm not quite sure what you want.
>> Feel free to apply a modified patch if you want,
>> as long as it removes the warnings.
>
> I do not understand too !
> Please explain us exactly what you want, or please merge the steve's patch
> asap.
> Note: I really think we need some sub-maintainers, specialized in specific
> part of the project.
>
>> Cheers,
>> Steve
>
> Laurent
There is standard way to handle types like int8_t, int 32_t, etc.
There is standard way to print them, because for int32_t there might
be different types
on different architectures.
Look at this:

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/inttypes.h.html

/* Macros for printing format specifiers.  */

/* Decimal notation.  */
# define PRId8          "d"
# define PRId16         "d"
# define PRId32         "d"
# define PRId64         __PRI64_PREFIX "d"

# define PRIdLEAST8     "d"
# define PRIdLEAST16    "d"
# define PRIdLEAST32    "d"
# define PRIdLEAST64    __PRI64_PREFIX "d"

# define PRIdFAST8      "d"
# define PRIdFAST16     __PRIPTR_PREFIX "d"
# define PRIdFAST32     __PRIPTR_PREFIX "d"
# define PRIdFAST64     __PRI64_PREFIX "d"


# define PRIi8          "i"
# define PRIi16         "i"
# define PRIi32         "i"
# define PRIi64         __PRI64_PREFIX "i"

# define PRIiLEAST8     "i"
# define PRIiLEAST16    "i"
# define PRIiLEAST32    "i"
# define PRIiLEAST64    __PRI64_PREFIX "i"

# define PRIiFAST8      "i"
# define PRIiFAST16     __PRIPTR_PREFIX "i"
# define PRIiFAST32     __PRIPTR_PREFIX "i"
# define PRIiFAST64     __PRI64_PREFIX "i"

...

I'd use these macros everywhere, where we need to print fixed-width types.
When we use C types like int or char, these macros shoult NOT be used,
and normal
specifiers like "%d" or "%ld" should be used instead. These macos are
just for stdint.h-
defined types, not for everything else.

usage is like this:
int32_t i;
...
printf("this is int32t %" PRIi32 "\n", i)

Or something like that.

Just my $.05

All the best,
S.
_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to