Hi,
Is it possible to use 64-bit values with chprintf?
Regards,
Vladimir
chprintf and 64-bit numbers
-
- Posts: 35
- Joined: Fri Feb 09, 2018 12:44 am
- Has thanked: 2 times
- Been thanked: 5 times
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: chprintf and 64-bit numbers
Hi,
Currently not, it is not meant for a full printf() replacement.
Giovanni
Currently not, it is not meant for a full printf() replacement.
Giovanni
-
- Posts: 35
- Joined: Fri Feb 09, 2018 12:44 am
- Has thanked: 2 times
- Been thanked: 5 times
Re: chprintf and 64-bit numbers
If I add the 64-bit support, would it be appropriate to add it to ChibiOS somehow?
Regards,
Vladimir
Regards,
Vladimir
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: chprintf and 64-bit numbers
Hi,
It depends on code size increase, it is just an utility and it is meant to run also on 8 bits cores, some compilers don't have 64 bits types at all.
Giovanni
It depends on code size increase, it is just an utility and it is meant to run also on 8 bits cores, some compilers don't have 64 bits types at all.
Giovanni
Re: chprintf and 64-bit numbers
Giovanni wrote:Hi,
It depends on code size increase, it is just an utility and it is meant to run also on 8 bits cores, some compilers don't have 64 bits types at all.
Giovanni
Maybe enable/disable dependent on 64-bit type support (c99 standard or later).
Or have a default setting which is processor dependent, with an option to override (default disable on 8-bit, F0; enable on F4, F7, H7 for example).
Or both.
-
- Posts: 35
- Joined: Fri Feb 09, 2018 12:44 am
- Has thanked: 2 times
- Been thanked: 5 times
Re: chprintf and 64-bit numbers
Giovanni wrote:Hi,
It depends on code size increase, it is just an utility and it is meant to run also on 8 bits cores, some compilers don't have 64 bits types at all.
Giovanni
In any case it should be coded with conditionals, like the following:
Code: Select all
#ifdef CHPRINTF_USE_LONGLONG
....
#endif // CHPRINTF_USE_LONGLONG
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: chprintf and 64-bit numbers
A conditional would be fine, note there are other conditionals, follow that pattern.
Giovanni
Giovanni
-
- Posts: 35
- Joined: Fri Feb 09, 2018 12:44 am
- Has thanked: 2 times
- Been thanked: 5 times
Re: chprintf and 64-bit numbers
Done. There can I send the patched files? This forum does not allow to attach .c files
Regards,
Vladimir
Regards,
Vladimir
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
-
- Posts: 35
- Joined: Fri Feb 09, 2018 12:44 am
- Has thanked: 2 times
- Been thanked: 5 times
Re: chprintf and 64-bit numbers
The modified chprintf.c attached.
Also, you'll need to add something like
to the chprintf.h
Regards,
Vladimir
Also, you'll need to add something like
Code: Select all
/**
* @brief Long long type support.
*/
#if !defined(CHPRINTF_USE_LONGLONG) || defined(__DOXYGEN__)
#define CHPRINTF_USE_LONGLONG TRUE
#endif
to the chprintf.h
Regards,
Vladimir
- Attachments
-
- chprintf.c.zip
- (2.96 KiB) Downloaded 184 times
Who is online
Users browsing this forum: No registered users and 15 guests