You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my opinion, the patch is a bit dangerous since it introduces C preprocessor and loads everything from iso_c_binding. Next time you will need to update it once more.
I agree, but see it as a temporary hack on the road to Fortran 2023. Loading the whole iso_c_binding module feels acceptable performance-wise, the module it is imported into is private anyway.
...and this as it fails (the make command is how I have always used it)
$ make FFLAGS='-std=f2018 $(SDL_CFLAGS) -O3' all example
gfortran -std=f2018 -O3 -fPIC -c src/c_util.F90 src/sdl2/sdl2_stdinc.f90 src/sdl2/sdl2_audio.f90 src/sdl2/sdl2_blendmode.f90 src/sdl2/sdl2_cpuinfo.f90 src/sdl2/sdl2_gamecontroller.f90 src/sdl2/sdl2_error.f90 src/sdl2/sdl2_events.f90 src/sdl2/sdl2_filesystem.f90 src/sdl2/sdl2_hints.f90 src/sdl2/sdl2_joystick.f90 src/sdl2/sdl2_keyboard.f90 src/sdl2/sdl2_log.f90 src/sdl2/sdl2_messagebox.f90 src/sdl2/sdl2_rect.f90 src/sdl2/sdl2_pixels.f90 src/sdl2/sdl2_platform.f90 src/sdl2/sdl2_scancode.f90 src/sdl2/sdl2_surface.f90 src/sdl2/sdl2_render.f90 src/sdl2/sdl2_keycode.f90 src/sdl2/sdl2_mouse.f90 src/sdl2/sdl2_rwops.f90 src/sdl2/sdl2_thread.f90 src/sdl2/sdl2_timer.f90 src/sdl2/sdl2_version.f90 src/sdl2/sdl2_video.f90 src/sdl2/sdl2_opengl.f90 src/sdl2.f90
src/c_util.F90:16:24:
16 | public :: c_uint16_t
| 1
Error: Symbol 'c_uint16_t' at (1) has no IMPLICIT type; did you mean 'c_int16_t'?
src/c_util.F90:17:24:
17 | public :: c_uint32_t
| 1
Error: Symbol 'c_uint32_t' at (1) has no IMPLICIT type; did you mean 'c_int32_t'?
src/c_util.F90:18:24:
18 | public :: c_uint64_t
| 1
Error: Symbol 'c_uint64_t' at (1) has no IMPLICIT type; did you mean 'c_int64_t'?
src/c_util.F90:15:23:
15 | public :: c_uint8_t
| 1
Error: Symbol 'c_uint8_t' at (1) has no IMPLICIT type; did you mean 'c_int8_t'?
src/c_util.F90:19:24:
19 | public :: c_unsigned
| 1
Error: Symbol 'c_unsigned' at (1) has no IMPLICIT type; did you mean 'c_associated'?
src/c_util.F90:20:29:
20 | public :: c_unsigned_char
| 1
Error: Symbol 'c_unsigned_char' at (1) has no IMPLICIT type; did you mean 'c_signed_char'?
src/c_util.F90:21:29:
21 | public :: c_unsigned_long
| 1
Error: Symbol 'c_unsigned_long' at (1) has no IMPLICIT type; did you mean 'c_signed_char'?
src/c_util.F90:22:34:
22 | public :: c_unsigned_long_long
| 1
Error: Symbol 'c_unsigned_long_long' at (1) has no IMPLICIT type; did you mean 'c_long_long'?
src/c_util.F90:23:30:
23 | public :: c_unsigned_short
| 1
Error: Symbol 'c_unsigned_short' at (1) has no IMPLICIT type; did you mean 'c_signed_char'?
src/sdl2/sdl2_events.f90:10:11:
10 | use :: c_util
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
src/sdl2/sdl2_log.f90:10:11:
10 | use :: c_util
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
src/sdl2/sdl2_messagebox.f90:10:11:
10 | use :: c_util, only: c_uint32_t
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
src/sdl2/sdl2_pixels.f90:10:11:
10 | use :: c_util
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
src/sdl2/sdl2_surface.f90:10:11:
10 | use :: c_util
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
src/sdl2/sdl2_render.f90:10:11:
10 | use :: c_util
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
src/sdl2/sdl2_mouse.f90:10:11:
10 | use :: c_util, only: c_uint32_t
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
src/sdl2/sdl2_timer.f90:10:11:
10 | use :: c_util, only: c_uint32_t, c_uint64_t
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
src/sdl2/sdl2_version.f90:10:11:
10 | use :: c_util, only: c_uint8_t
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
src/sdl2/sdl2_video.f90:10:11:
10 | use :: c_util, only: c_uint32_t
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
src/sdl2.f90:11:11:
11 | use :: c_util
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
make: *** [Makefile:75: libsdl2.a] Error 1
$ make FFLAGS="-std=f2018 `sdl2-config --cflags` -O3" all examples
gfortran -std=f2018 -IC:/msys64/ucrt64/include/SDL2 -Dmain=SDL_main -O3 -fPIC -c src/c_util.F90 src/sdl2/sdl2_stdinc.f90 src/sdl2/sdl2_audio.f90 src/sdl2/sdl2_blendmode.f90 src/sdl2/sdl2_cpuinfo.f90 src/sdl2/sdl2_gamecontroller.f90 src/sdl2/sdl2_error.f90 src/sdl2/sdl2_events.f90 src/sdl2/sdl2_filesystem.f90 src/sdl2/sdl2_hints.f90 src/sdl2/sdl2_joystick.f90 src/sdl2/sdl2_keyboard.f90 src/sdl2/sdl2_log.f90 src/sdl2/sdl2_messagebox.f90 src/sdl2/sdl2_rect.f90 src/sdl2/sdl2_pixels.f90 src/sdl2/sdl2_platform.f90 src/sdl2/sdl2_scancode.f90 src/sdl2/sdl2_surface.f90 src/sdl2/sdl2_render.f90 src/sdl2/sdl2_keycode.f90 src/sdl2/sdl2_mouse.f90 src/sdl2/sdl2_rwops.f90 src/sdl2/sdl2_thread.f90 src/sdl2/sdl2_timer.f90 src/sdl2/sdl2_version.f90 src/sdl2/sdl2_video.f90 src/sdl2/sdl2_opengl.f90 src/sdl2.f90
src/c_util.F90:16:24:
16 | public :: c_uint16_t
| 1
Error: Symbol 'c_uint16_t' at (1) has no IMPLICIT type; did you mean 'c_int16_t'?
src/c_util.F90:17:24:
17 | public :: c_uint32_t
| 1
Error: Symbol 'c_uint32_t' at (1) has no IMPLICIT type; did you mean 'c_int32_t'?
src/c_util.F90:18:24:
18 | public :: c_uint64_t
| 1
Error: Symbol 'c_uint64_t' at (1) has no IMPLICIT type; did you mean 'c_int64_t'?
src/c_util.F90:15:23:
15 | public :: c_uint8_t
| 1
Error: Symbol 'c_uint8_t' at (1) has no IMPLICIT type; did you mean 'c_int8_t'?
src/c_util.F90:19:24:
19 | public :: c_unsigned
| 1
Error: Symbol 'c_unsigned' at (1) has no IMPLICIT type; did you mean 'c_associated'?
src/c_util.F90:20:29:
20 | public :: c_unsigned_char
| 1
Error: Symbol 'c_unsigned_char' at (1) has no IMPLICIT type; did you mean 'c_signed_char'?
src/c_util.F90:21:29:
21 | public :: c_unsigned_long
| 1
Error: Symbol 'c_unsigned_long' at (1) has no IMPLICIT type; did you mean 'c_signed_char'?
src/c_util.F90:22:34:
22 | public :: c_unsigned_long_long
| 1
Error: Symbol 'c_unsigned_long_long' at (1) has no IMPLICIT type; did you mean 'c_long_long'?
src/c_util.F90:23:30:
23 | public :: c_unsigned_short
| 1
Error: Symbol 'c_unsigned_short' at (1) has no IMPLICIT type; did you mean 'c_signed_char'?
src/sdl2/sdl2_events.f90:10:11:
10 | use :: c_util
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
src/sdl2/sdl2_log.f90:10:11:
10 | use :: c_util
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
src/sdl2/sdl2_messagebox.f90:10:11:
10 | use :: c_util, only: c_uint32_t
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
src/sdl2/sdl2_pixels.f90:10:11:
10 | use :: c_util
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
src/sdl2/sdl2_surface.f90:10:11:
10 | use :: c_util
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
src/sdl2/sdl2_render.f90:10:11:
10 | use :: c_util
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
src/sdl2/sdl2_mouse.f90:10:11:
10 | use :: c_util, only: c_uint32_t
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
src/sdl2/sdl2_timer.f90:10:11:
10 | use :: c_util, only: c_uint32_t, c_uint64_t
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
src/sdl2/sdl2_version.f90:10:11:
10 | use :: c_util, only: c_uint8_t
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
src/sdl2/sdl2_video.f90:10:11:
10 | use :: c_util, only: c_uint32_t
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
src/sdl2.f90:11:11:
11 | use :: c_util
| 1
Fatal Error: Cannot open module file 'c_util.mod' for reading at (1): No such file or directory
compilation terminated.
make: *** [Makefile:75: libsdl2.a] Error 1
The unsigned argument has to be passed to GNU Fortran 15:
I tested the following.
It build but emits a lot of warnings and, sincerely, all these changes look workarounds and not a clean solution. Before the changes for flang support, the old repo builds OB without warnings and without -funsigned with GFortran 15. In any case, flang is not supported because it segments faults as I wrote here
$ make LIBGL='-lopengl32' LIBGLU='-lglu32' FFLAGS="-funsigned -Wall -std=f2018 -fmax-errors=1 `sdl2-config --cflags` -O3
" all examples
gfortran -funsigned -Wall -std=f2018 -fmax-errors=1 -IC:/msys64/ucrt64/include/SDL2 -Dmain=SDL_main -O3 -fPIC -c src/c_util.F90 src/sdl2/sdl2_stdinc.f90 src/sdl2/sdl2_audio.f90 src/sdl2/sdl2_blendmode.f90 src/sdl2/sdl2_cpuinfo.f90 src/sdl2/sdl2_gamecontroller.f90 src/sdl2/sdl2_error.f90 src/sdl2/sdl2_events.f90 src/sdl2/sdl2_filesystem.f90 src/sdl2/sdl2_hints.f90 src/sdl2/sdl2_joystick.f90 src/sdl2/sdl2_keyboard.f90 src/sdl2/sdl2_log.f90 src/sdl2/sdl2_messagebox.f90 src/sdl2/sdl2_rect.f90 src/sdl2/sdl2_pixels.f90 src/sdl2/sdl2_platform.f90 src/sdl2/sdl2_scancode.f90 src/sdl2/sdl2_surface.f90 src/sdl2/sdl2_render.f90 src/sdl2/sdl2_keycode.f90 src/sdl2/sdl2_mouse.f90 src/sdl2/sdl2_rwops.f90 src/sdl2/sdl2_thread.f90 src/sdl2/sdl2_timer.f90 src/sdl2/sdl2_version.f90 src/sdl2/sdl2_video.f90 src/sdl2/sdl2_opengl.f90 src/sdl2.f90
src/sdl2/sdl2_events.f90:66:15:
66 | integer(kind=c_uint32_t) :: type
| 1
Warning: C kind type parameter is for type UNSIGNED but type at (1) is INTEGER
src/sdl2/sdl2_events.f90:67:15:
67 | integer(kind=c_uint32_t) :: timestamp
| 1
Warning: C kind type parameter is for type UNSIGNED but type at (1) is INTEGER
src/sdl2/sdl2_events.f90:72:15:
72 | integer(kind=c_uint32_t) :: type
| 1
Warning: C kind type parameter is for type UNSIGNED but type at (1) is INTEGER
src/sdl2/sdl2_events.f90:73:15:
[...]
Warning: C kind type parameter is for type UNSIGNED but type at (1) is INTEGER
ar rcs libsdl2.a sdl2.o
gfortran -funsigned -Wall -std=f2018 -fmax-errors=1 -IC:/msys64/ucrt64/include/SDL2 -Dmain=SDL_main -O3 -fPIC -c src/sdl2_image.f90
ar rcs libsdl2_image.a sdl2_image.o
gfortran -funsigned -Wall -std=f2018 -fmax-errors=1 -IC:/msys64/ucrt64/include/SDL2 -Dmain=SDL_main -O3 -fPIC -c src/c_util.F90 src/sdl2_mixer.f90
src/sdl2_mixer.f90:90:19:
90 | integer(kind=c_uint32_t), intent(in), value :: format
| 1
Warning: C kind type parameter is for type UNSIGNED but type at (1) is INTEGER
ar rcs libsdl2_mixer.a sdl2_mixer.o
gfortran -funsigned -Wall -std=f2018 -fmax-errors=1 -IC:/msys64/ucrt64/include/SDL2 -Dmain=SDL_main -O3 -fPIC -c src/sdl2_ttf.f90
....
$ gfortran -cpp `sdl2-config --cflags` -O3 -fPIC -c src/c_util.f90
src/c_util.f90:12:89:
12 | use, intrinsic :: iso_c_binding, only: c_uint8_t, c_uint16_t, c_uint32_t, c_uint64_t, c_unsigned, c_unsigned_char, &
| 1
Error: The symbol 'c_unsigned', referenced at (1), is not in the selected standard
src/c_util.f90:13:81:
13 | c_unsigned_long, c_unsigned_long_long, c_unsigned_short
| 1
Error: The symbol 'c_unsigned_short', referenced at (1), is not in the selected standard
src/c_util.f90:12:101:
...
I see the repo has been updated today. It builds with GFortran,
make LIBGL='-lopengl32' LIBGLU='-lglu32' FFLAGS='-Wall -std=f2018 -fmax-errors=1 -O3' all examples
there is just this warning:
examples/gl3d.f90:201:5:
201 | subroutine gl_perspective(fovy, aspect, znear, zfar)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
Warning: 'gl_perspective' defined but not used [-Wunused-function]
All examples seems to work, at least they does not segment fault, core dump etc.
With Flang the repo segment faults as I already flagged. I used these commands to try the build:
1) make LIBGL='-lopengl32' LIBGLU='-lglu32' FC='flang' FFLAGS='-std=f2018 -O3' all examples
2) make LIBGL='-lopengl32' LIBGLU='-lglu32' FC='flang' FFLAGS='-DHAS_UNSIGNED -std=f2018 -O3' all examples
3) make LIBGL='-lopengl32' LIBGLU='-lglu32' FC='flang' FFLAGS='-funsigned -std=f2018 -O3' all examples
All the above on Windows 11, MSYS2/UCRT64, GFortran 15.2.0
@angelog0, could you please try make LIBGL='-lopengl32' LIBGLU='-lglu32' FC='flang' FFLAGS='-std=f2018 -O3 -g' all examples and see, what causes SegFaults.
Activity
interkosmos commentedon Sep 22, 2025
A preprocessor macro has been added with the latest commit for Flang compatiblity. Thank you for reporting.
foxtran commentedon Sep 23, 2025
In my opinion, the patch is a bit dangerous since it introduces C preprocessor and loads everything from
iso_c_binding. Next time you will need to update it once more.interkosmos commentedon Sep 23, 2025
I agree, but see it as a temporary hack on the road to Fortran 2023. Loading the whole
iso_c_bindingmodule feels acceptable performance-wise, the module it is imported into is private anyway.angelog0 commentedon Sep 23, 2025
Maybe we need now instructions on how to build it because the repo does not build with
gfortranany more.gfortranis...and this as it fails (the
makecommand is how I have always used it)interkosmos commentedon Sep 23, 2025
Using GNU Fortran 14.2:
Builds just fine:
The variable
SDL_CFLAGShas been removed from the Makefile in master.Edit: According to the GCC documentation, the unsigned constants are supported since GNU Fortran 15.1.
foxtran commentedon Sep 23, 2025
Only if
-funsignedis passed.interkosmos commentedon Sep 23, 2025
That makes portability more cumbersome than expected.
angelog0 commentedon Sep 23, 2025
Here it fails. For example:
The old repo builds OB:
Using
flangwith the new repo segment faultsinterkosmos commentedon Sep 24, 2025
The unsigned argument has to be passed to GNU Fortran 15:
I’ve made some changes to the
c_utilmodule, it should be compatible to gfortran 14 and 15 now.angelog0 commentedon Sep 24, 2025
I tested the following.
It build but emits a lot of warnings and, sincerely, all these changes look workarounds and not a clean solution. Before the changes for
flangsupport, the old repo builds OB without warnings and without-funsignedwith GFortran 15. In any case,flangis not supported because it segments faults as I wrote hereangelog0 commentedon Sep 24, 2025
Just for completeness...
Applying this patch to old
c_utils.f90, no preprocessing,builds OB both with GFortran 15 and Flang 21.
Instead the new
c_utils.f90, with preprocessing,Maybe you need to avoid preprocessing and patch the files using the
use :: only..toxtran commentedon Sep 24, 2025
Just add
-cppflag.angelog0 commentedon Sep 24, 2025
with Flang builds:
flang -cppsdl2-config --cflags-O3 -fPIC -c src/c_util.f90The command
produces the same warnings, while
produces the same segment fault.
toxtran commentedon Sep 24, 2025
Ok. It looks strange.. I will have a look at morning.. and probably patch :-)
interkosmos commentedon Sep 25, 2025
I’m building GCC 15.2 from source now and will investigate further.
foxtran commentedon Sep 25, 2025
@interkosmos, see #24
Morning did not happen today :(
angelog0 commentedon Sep 28, 2025
I see the repo has been updated today. It builds with GFortran,
there is just this warning:
All examples seems to work, at least they does not segment fault, core dump etc.
With Flang the repo segment faults as I already flagged. I used these commands to try the build:
All the above on Windows 11, MSYS2/UCRT64, GFortran 15.2.0
angelog0 commentedon Sep 28, 2025
In the
README.mdthere is written:but, as I wrote above, on Windows+MSYS2/UCRT64+GFortran 15.2.0, I do not need it. It just builds with
foxtran commentedon Oct 2, 2025
Oops. One have to use
-funsigned -DHAS_UNSIGNED. Only in that case, unsigned types will be used. The same is for flang.foxtran commentedon Oct 2, 2025
@angelog0, could you please try
make LIBGL='-lopengl32' LIBGLU='-lglu32' FC='flang' FFLAGS='-std=f2018 -O3 -g' all examplesand see, what causes SegFaults.angelog0 commentedon Oct 2, 2025
I already sent what segment fault asked
I repeat here (just adding
-gflag)flang.output.gz
flang_failure.tar.gz
I can't help any more than that, my mind refuse to use
gdband friends, someone else has to do the work...foxtran commentedon Oct 2, 2025
Ah. Got it. Now, it is definitely a compiler bug.
foxtran commentedon Oct 2, 2025
flang@0d92b7f9021e3a0c891db9ffb4eac4fc721981f8 runs given command without errors... But is it for Linux. I do not have an access to Windows for checking.
interkosmos commentedon Oct 22, 2025
Thank you, seems to be solved for now. Please reopen if there are any persistent issues.