Ever since I started programming in C I have known/seen everyone to use the following convention when declaring variables using typedefs as shown below:
int32_t *data_value;
const int16_t *Order_Of_Mag;
uint16_t min_change;
uint8_t eeprom_save_flag;
I understand part of the reason is for portability between different architectures. Does anyone know when and/or what standard dictates this method for declaration?
Also what’s the recommended method for dealing with standard library (stdio.h) functions that require the use of char, given that a char is neither uint8_t nor int8_t (see example functions below)
sscanf(const char *format)
int atio(const char *s)
Thanks in advance
The only standards that I know of that require you to use such typedefs are project/company specific coding conventions. Those coding conventions then also specify exactly which typedefs (or even macros) to use, so it might be
UINT32instead ofuint32_tthat you must useAs for the choice between
char,uint8_torint8_t, the default should be to usecharfor character data (i.e. strings and characters) anduint8_torint8_tfor small numbers.