GDISP: Move extern GDISPVMT declarations outside of function body

This prevents generation of "nested-externs" compiler warnings.
develop
Joel Bodenmann 2021-08-13 11:51:47 +02:00
parent 37450998e1
commit cf01cb2e7c
1 changed files with 10 additions and 6 deletions

View File

@ -555,15 +555,22 @@ static void line_clip(GDisplay *g) {
/* Driver exported functions. */ /* Driver exported functions. */
/*===========================================================================*/ /*===========================================================================*/
// Gather GDISP VMT(S)
// These are only needed in _gdispInit(). However, we want to prevent generating nested-externs compiler warnings.
#if defined(GDISP_DRIVER_LIST)
extern GDISPVMTLIST GDISP_DRIVER_LIST;
#else
extern const GDISPVMT GDISPVMT_OnlyOne[1];
#endif
void _gdispInit(void) void _gdispInit(void)
{ {
// GDISP_DRIVER_LIST is defined - create each driver instance // GDISP_DRIVER_LIST is defined - create each driver instance
#if defined(GDISP_DRIVER_LIST) #if defined(GDISP_DRIVER_LIST)
{ {
unsigned i; unsigned i;
typedef const GDISPVMT const GDISPVMTLIST[1]; typedef const GDISPVMT const GDISPVMTLIST[1];
extern GDISPVMTLIST GDISP_DRIVER_LIST;
static const GDISPVMT * const dclist[] = {GDISP_DRIVER_LIST}; static const GDISPVMT * const dclist[] = {GDISP_DRIVER_LIST};
for(i = 0; i < sizeof(dclist)/sizeof(dclist[0]); i++) { for(i = 0; i < sizeof(dclist)/sizeof(dclist[0]); i++) {
@ -573,8 +580,7 @@ void _gdispInit(void)
} }
#elif GDISP_TOTAL_DISPLAYS > 1 #elif GDISP_TOTAL_DISPLAYS > 1
{ {
unsigned i; unsigned i;
extern const GDISPVMT GDISPVMT_OnlyOne[1];
if (!(GDISPVMT_OnlyOne->d.flags & GDISP_VFLG_DYNAMICONLY)) { if (!(GDISPVMT_OnlyOne->d.flags & GDISP_VFLG_DYNAMICONLY)) {
for(i = 0; i < GDISP_TOTAL_DISPLAYS; i++) for(i = 0; i < GDISP_TOTAL_DISPLAYS; i++)
@ -583,8 +589,6 @@ void _gdispInit(void)
} }
#else #else
{ {
extern const GDISPVMT GDISPVMT_OnlyOne[1];
if (!(GDISPVMT_OnlyOne->d.flags & GDISP_VFLG_DYNAMICONLY)) if (!(GDISPVMT_OnlyOne->d.flags & GDISP_VFLG_DYNAMICONLY))
gdriverRegister(&GDISPVMT_OnlyOne->d, 0); gdriverRegister(&GDISPVMT_OnlyOne->d, 0);
} }