lv2 / pugl

A minimal portable API for embeddable GUIs
https://gitlab.com/lv2/pugl/
ISC License
181 stars 35 forks source link

Fix missing field initializers for C vs C++ on win32 code #93

Closed falkTX closed 2 years ago

falkTX commented 2 years ago

Similar to #87 but applies to win32 code now. Warnings reported by mingw:

src/pugl-upstream/src/win.c: In function ‘bool DGL::puglRegisterWindowClass(const char*)’:
src/pugl-upstream/src/win.c:83:21: warning: missing initializer for member ‘tagWNDCLASSEXA::style’ [-Wmissing-field-initializers]
   83 |   WNDCLASSEX wc = {0};
      |                     ^
src/pugl-upstream/src/win.c:83:21: warning: missing initializer for member ‘tagWNDCLASSEXA::lpfnWndProc’ [-Wmissing-field-initializers]
src/pugl-upstream/src/win.c:83:21: warning: missing initializer for member ‘tagWNDCLASSEXA::cbClsExtra’ [-Wmissing-field-initializers]
src/pugl-upstream/src/win.c:83:21: warning: missing initializer for member ‘tagWNDCLASSEXA::cbWndExtra’ [-Wmissing-field-initializers]
src/pugl-upstream/src/win.c:83:21: warning: missing initializer for member ‘tagWNDCLASSEXA::hInstance’ [-Wmissing-field-initializers]
src/pugl-upstream/src/win.c:83:21: warning: missing initializer for member ‘tagWNDCLASSEXA::hIcon’ [-Wmissing-field-initializers]
src/pugl-upstream/src/win.c:83:21: warning: missing initializer for member ‘tagWNDCLASSEXA::hCursor’ [-Wmissing-field-initializers]
src/pugl-upstream/src/win.c:83:21: warning: missing initializer for member ‘tagWNDCLASSEXA::hbrBackground’ [-Wmissing-field-initializers]
src/pugl-upstream/src/win.c:83:21: warning: missing initializer for member ‘tagWNDCLASSEXA::lpszMenuName’ [-Wmissing-field-initializers]
src/pugl-upstream/src/win.c:83:21: warning: missing initializer for member ‘tagWNDCLASSEXA::lpszClassName’ [-Wmissing-field-initializers]
src/pugl-upstream/src/win.c:83:21: warning: missing initializer for member ‘tagWNDCLASSEXA::hIconSm’ [-Wmissing-field-initializers]
src/pugl-upstream/src/win.c: In function ‘LRESULT DGL::handleMessage(DGL::PuglView*, UINT, WPARAM, LPARAM)’:
src/pugl-upstream/src/win.c:692:31: warning: missing initializer for member ‘tagTRACKMOUSEEVENT::dwFlags’ [-Wmissing-field-initializers]
  692 |       TRACKMOUSEEVENT tme = {0};
      |                               ^
src/pugl-upstream/src/win.c:692:31: warning: missing initializer for member ‘tagTRACKMOUSEEVENT::hwndTrack’ [-Wmissing-field-initializers]
src/pugl-upstream/src/win.c:692:31: warning: missing initializer for member ‘tagTRACKMOUSEEVENT::dwHoverTime’ [-Wmissing-field-initializers]

maybe the macro should go into a common header?

drobilla commented 2 years ago

Thanks, but, y'know, we'd both be a lot less annoyed by a lot of things if you'd just build the damned library normally and not #include the implementation in a different bloody programming language for no particular reason ;)

falkTX commented 2 years ago

One reason is for having a safe namespace where I can use 2 or more pugl versions in the same process. I am using pugl on the host side for a few little things, which can directly conflict with pugl from plugins. Gets specially annoying in debug builds where symbol conflicts can easily get in the way.

drobilla commented 2 years ago

Fair enough, although I feel like if that's an issue, it means plugins have a sloppy public symbol table that should be fixed anyway...

falkTX commented 2 years ago

developers can be lazy bastards though ;) since my usecase is for a plugin framework, I go a bit out of the way to ensure proper namespacing. gets quite annoying on macOS though...

drobilla commented 2 years ago

I guess if you mostly live in C++ land, that's more or less viable. In C land, violating the integrity/privacy of compilation units in particular will end very not-well (in a sense it's removing proper namespacing). This is why I don't support that for any other library, but Pugl is a bit of a weird case.

drobilla commented 2 years ago

Anyway!

Merged as decde99, thanks.