Make C API headers compatible with C++11 and onward

,

Hello,

The latest public version of SDK doesn't compile with C++17 due to a few little issues which I had to patch locally, example:

 static inline LCDRect LCDRect_translate(LCDRect r, int dx, int dy)
 {
+	LCDRect rect = { r.left + dx, r.right + dx, r.top + dy, r.bottom + dy };
+	return rect;
-	return (LCDRect){ .left = r.left + dx, .right = r.right + dx, .top = r.top + dy, .bottom = r.bottom + dy };
 }

So it's due to

  • Using designated initializers which are available in C++20, but I think there are many programmers who still use older versions.
  • Expressions like return (LCDRect){...} are not valid in C++, instead the struct can be allocated on stack and returned by value.

There is a couple of instances of this

  • LCDMakeRect, LCDRect_translate in pd_api_gfx.h
  • PDRectMake in pd_api_sprite.h
  • There may be more...

Hope this is a reasonable request.

Thanks!

Good suggestion, thanks!