tophat2d / tophat

:tophat: a 2d game library for Umka
https://tophat2d.dev
BSD 3-Clause "New" or "Revised" License
69 stars 5 forks source link

Cross-compiler warnings #153

Open vtereshkov opened 5 months ago

vtereshkov commented 5 months ago

At least the mip_level and dpi_scale issues can be fixed easily.

src/image.c: In function ‘th_image_get_data’:
src/image.c:84:7: warning: ‘glBindTexture’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
   84 |  void glBindTexture(GLenum target, GLuint texture);
      |       ^~~~~~~~~~~~~
src/image.c:85:9: warning: ‘glGetError’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
   85 |  GLenum glGetError();
      |         ^~~~~~~~~~
src/image.c:86:7: warning: ‘glGetTexImage’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
   86 |  void glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, void *pixels);
      |       ^~~~~~~~~~~~~
src/image.c: In function ‘th_image_create_render_target’:
src/image.c:144:6: warning: missing initializer for field ‘mip_level’ of ‘sg_pass_attachment_desc’ {aka ‘struct sg_pass_attachment_desc’} [-Wmissing-field-initializers]
  144 |      .depth_stencil_attachment.image = t->depth,
      |      ^
In file included from src/image.c:8:
lib/sokol/sokol_gfx.h:2909:9: note: ‘mip_level’ declared here
 2909 |     int mip_level;
      |         ^~~~~~~~~
In file included from src/sokol.c:15:
lib/sokol/sokol_app.h:2069: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 2069 |             #pragma comment (linker, "/subsystem:windows")
      | 
In file included from src/sokol.c:15:
lib/sokol/sokol_app.h:2075: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 2075 |     #pragma comment (lib, "kernel32")
      | 
lib/sokol/sokol_app.h:2076: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 2076 |     #pragma comment (lib, "user32")
      | 
lib/sokol/sokol_app.h:2077: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 2077 |     #pragma comment (lib, "shell32")    /* CommandLineToArgvW, DragQueryFileW, DragFinished */
      | 
lib/sokol/sokol_app.h:2078: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 2078 |     #pragma comment (lib, "gdi32")
      | 
In file included from src/sokol.c:16:
lib/sokol/sokol_gfx.h:4225: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 4225 |                 #pragma comment (lib, "kernel32")   // GetProcAddress()
      | 
In file included from src/sokol.c:16:
lib/sokol/sokol_gfx.h: In function ‘_sg_gl_load_opengl’:
lib/sokol/sokol_gfx.h:6675:48: warning: cast between incompatible function types from ‘FARPROC’ {aka ‘long long int (*)()’} to ‘INT_PTR (* (*)(const CHAR *))()’ {aka ‘long long int (* (*)(const char *))()’} [-Wcast-function-type]
 6675 |     _sg_wglGetProcAddress wgl_getprocaddress = (_sg_wglGetProcAddress) GetProcAddress(_sg.gl.opengl32_dll, "wglGetProcAddress");
      |                                                ^
src/window.c: In function ‘th_get_window_handle’:
src/window.c:238:9: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  238 |  return sapp_win32_get_hwnd();
      |         ^~~~~~~~~~~~~~~~~~~~~
src/window.c: In function ‘th_window_set_dims’:
src/window.c:257:5: warning: unused variable ‘dpi_scale’ [-Wunused-variable]
  257 |  fu dpi_scale = th_window_dpi_scale();
      |     ^~~~~~~~~
lib/umka/src/umka_api.c: In function ‘umkaGetMapItem’:
lib/umka/src/umka_api.c:255:53: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  255 |     return vmGetMapNodeData(&comp->vm, (Map *)map, *(Slot *)&key);
      |                                                     ^~~~~~~~~~~~
skejeton commented 5 months ago

There's actually a fair amount of warnings on MSVC too, I'll open an issue.

vtereshkov commented 5 months ago

@skejeton One more warning now:

src/main.c:371:1: warning: control reaches end of non-void function

By the way, why do we need this WinMain() at all?

skejeton commented 2 weeks ago

By the way, why do we need this WinMain() at all?

WinMain is used for builds without the console window.