gdi: fix CXX_BUILD=1 by hoisting struct gdi_overlay to file scope

struct gdi_overlay was defined inline inside the 'struct gdi' body in
gdi_defines.h. In C the tag leaks to file scope, so gdi_gfx.c could
freely declare 'struct gdi_overlay *o'. In C++ a struct defined inside
another struct is scoped to the enclosing type (gdi::gdi_overlay), so
under CXX_BUILD=1 the file-scope references in gdi_overlay_load() and
gdi_overlays_render() resolved to a different, incomplete
'gdi_overlay', producing:

  cannot convert 'gdi::gdi_overlay*' to
    'gdi_overlay_load(...)::gdi_overlay*'
  invalid use of incomplete type 'struct ...::gdi_overlay'

Move the struct definition out to file scope (still under
HAVE_OVERLAY) and reference it as 'struct gdi_overlay *overlays;' in
the member. Single shared type in both C and C++; layout and the C
build are unchanged. Same fix as the sdl2 driver in a624ae1.

Follow-up to the CXX_BUILD fixes in 059ca26 / 7712d87 / a624ae1 /
8102d80.
This commit is contained in:
libretroadmin authored and libretroadmin committed 2026-06-25 10:04:40 +02:00
1 parent 8102d806de
commit 9c4e30a22e
1 file changed
+26 -11
+26 -11
View File
@@ -25,6 +25,22 @@
#include "../video_defines.h"
#ifdef HAVE_OVERLAY
/* On-screen input overlay entry. Defined at file scope (not inside
* struct gdi) so the tag resolves to the same type in both C and C++;
* see the note at the 'overlays' member below. */
struct gdi_overlay
{
HBITMAP bmp;
unsigned tex_w;
unsigned tex_h;
float tex_coords[4];
float vert_coords[4];
float alpha_mod;
bool fullscreen;
};
#endif
typedef struct gdi
{
#ifndef __WINRT__
@@ -170,17 +186,16 @@ typedef struct gdi
* is a 4-float (x, y, w, h) tuple in 0..1 space (window space
* for vert when fullscreen, viewport space otherwise; texture
* space for tex). vertex_geom flips y the same way d3d8 does
* to keep the same on-screen behaviour. */
struct gdi_overlay
{
HBITMAP bmp;
unsigned tex_w;
unsigned tex_h;
float tex_coords[4];
float vert_coords[4];
float alpha_mod;
bool fullscreen;
} *overlays;
* to keep the same on-screen behaviour.
*
* Note: struct gdi_overlay is defined at file scope (above this
* typedef) rather than inline here. Defining a struct inside
* another struct's body scopes the tag to the enclosing type in
* C++ (gdi::gdi_overlay), so under CXX_BUILD a file-scope
* 'struct gdi_overlay *' in gdi_gfx.c would refer to a different,
* incomplete type. A top-level definition keeps a single shared
* type in both C and C++. */
struct gdi_overlay *overlays;
unsigned overlays_size;
bool overlays_enabled;
#endif