interkosmos/fortran-sdl2

Still warnings after last upgrade

Closed this issue · 3 comments

I see you have added -Wall to build the examples, but I think, then, you have to add the same to build the modules:

--- Makefile~   2018-09-10 14:29:02.473566200 +0200
+++ Makefile    2018-09-10 14:40:28.729586700 +0200
@@ -35,16 +35,16 @@
 sdl2_ttf: $(TTF_OBJ)

 $(SDL_OBJ):
-       $(FC) -c $(SDL_SRC)
+       $(FC) -Wall -c $(SDL_SRC)

 $(IMG_OBJ):
-       $(FC) -c $(IMG_SRC)
+       $(FC) -Wall -c $(IMG_SRC)

 $(MIX_OBJ):
-       $(FC) -c $(MIX_SRC)
+       $(FC) -Wall -c $(MIX_SRC)

 $(TTF_OBJ):
-       $(FC) -c $(TTF_SRC)
+       $(FC) -Wall -c $(TTF_SRC)

 $(WINDOW): $(EXAMPLES)/$(WINDOW)/$(WINDOW).f90 $(SDL_OBJ)
        $(FC) $(CFLAGS) -o $@ $? $(LDFLAGS)

This would trigger some warning in sdl2.f90 which can be easily fixed with:

--- sdl2.f90~   2018-09-10 13:35:02.000000000 +0200
+++ sdl2.f90    2018-09-10 14:47:53.505814100 +0200
@@ -1036,7 +1036,7 @@
         function sdl_get_video_driver_(index) bind(c, name='SDL_GetVideoDriver')
             use, intrinsic :: iso_c_binding
             implicit none
-            integer, intent(in) :: index
+            integer(c_int), intent(in) :: index
             type(c_ptr)         :: sdl_get_video_driver_
         end function sdl_get_video_driver_

@@ -1501,7 +1501,6 @@
             type(c_ptr)                     :: ptr
             character(kind=c_char), pointer :: ptrs(:)
             character(len=10)               :: sdl_get_current_video_driver
-            integer                         :: i

             ptr = sdl_get_current_video_driver_()

@@ -1521,7 +1520,6 @@
             character(len=100)              :: sdl_get_error
             type(c_ptr)                     :: ptr
             character(kind=c_char), pointer :: ptrs(:)
-            integer                         :: i

             ptr = sdl_get_error_()

@@ -1556,7 +1554,6 @@
             character(len=100)                 :: sdl_get_hint
             type(c_ptr)                        :: ptr
             character(kind=c_char), pointer    :: ptrs(:)
-            integer                            :: i

             ptr = sdl_get_hint_(name // c_null_char)

@@ -1589,7 +1586,6 @@
             type(c_ptr)                        :: ptr
             character(kind=c_char), pointer    :: ptrs(:)
             character(len=10)                  :: sdl_get_video_driver
-            integer                            :: i

             ptr = sdl_get_video_driver_(index)

The Makefile has been ported to GNU make. Please have a look again.

Thanks for the GNU make porting, but my above observations regarded a few warnings about modules compilation.

Please, re-read this. If you add -Wall also to build the modules you will find:

$ gfortran -Wall -c sdl2.f90
sdl2.f90:1031:44:

         function sdl_get_video_driver_(index) bind(c, name='SDL_GetVideoDriver')
                                            1
Warning: Variable 'index' at (1) is a dummy argument of the BIND(C) procedure 'sdl_get_video_driver_' but may not be C interoperable [-Wc-binding-type]
sdl2.f90:1587:51:

             integer                            :: i
                                                   1
Warning: Unused variable 'i' declared at (1) [-Wunused-variable]
sdl2.f90:1554:51:

             integer                            :: i
                                                   1
Warning: Unused variable 'i' declared at (1) [-Wunused-variable]
sdl2.f90:1519:48:

             integer                         :: i
                                                1
Warning: Unused variable 'i' declared at (1) [-Wunused-variable]
sdl2.f90:1499:48:

             integer                         :: i
                                                1
Warning: Unused variable 'i' declared at (1) [-Wunused-variable]

Here there is a quick fix...

Ah, sorry, missed that. Has been committed. Thank you.