The schar and uchar macros can conflict with user code that uses those names for other things in a local scope. e.g.
Code: Select all
#include "usbdrv.h"
void f( void )
{
int schar = 123; // error: two or more data types in declaration specifiers
}
If they were typedefs, this would be fine:
Code: Select all
typedef signed char schar;
void f( void )
{
int schar = 123; // no error
}
I realize that the macro might serve a second purpose: to avoid a duplicate typedef in case someone else has also defined schar:
Code: Select all
// other.h
#define schar signed char
// usbdrv.h
#ifndef schar // no problem, already defined so this is skipped
#define schar signed char
#endif
This serves the same purpose but doesn't conflict with user code using the name locally:
Code: Select all
#ifndef schar
#define schar schar
typedef signed char schar;
#endif
void f( void )
{
int schar = 123; // no error
}
Ideally a library's header file only defines things needed by the user, and doesn't introduce things like schar and uchar into the global space at all, especially as macros, them being lowercase. Things for the implementer's convenience ideally have the library's prefix in their names.