ada-game-framework / sdlada

Ada 2022 bindings to SDL 2
zlib License
117 stars 37 forks source link

Possible Newer Version of GNAT not compiling this project. #74

Open coffeebe4code opened 3 years ago

coffeebe4code commented 3 years ago

Originally reported here. My suspicion is that the latest version of ada has a new feature which does not allow this anonymous type usage anymore.

[Ada]          sdl-video-palettes.adb
sdl-video-palettes.adb:146:41: error: expected type "Palette_Constant_Access" defined at sdl-video-palettes.ads:124
sdl-video-palettes.adb:146:41: error: found type access to "Palette'CLASS" defined at line 69
sdl-video-palettes.adb:163:41: error: expected type "Palette_Constant_Access" defined at sdl-video-palettes.ads:124
sdl-video-palettes.adb:163:41: error: found type access to "Palette'CLASS" defined at line 69
Lucretia commented 3 years ago

Paste the output of gcc -v

coffeebe4code commented 3 years ago
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/christopher/opt/GNAT/2021/bin/../libexec/gcc/x86_64-pc-linux-gnu/10.3.1/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
Target: x86_64-pc-linux-gnu
Configured with: ../src/configure --enable-languages=ada,c,c++ --enable-checking=release --enable-dual-exceptions --enable-offload-targets=nvptx-none --enable-_cxa_atexit --enable-threads=posix --with-bugurl=URL:mailto:report@adacore.com --disable-nls --without-libiconv-prefix --disable-libstdcxx-pch --disable-libada --disable-multilib --enable-libstdcxx --with-mpfr=/it/sbx/a2c2/x86_64-linux/mpfr-3.1.5/install --with-gmp=/it/sbx/a2c2/x86_64-linux/gmp-6.1.2/install --with-mpc=/it/sbx/a2c2/x86_64-linux/mpc-1.0.3/install --with-build-time-tools=/it/sbx/a2c2/x86_64-linux/gcc-c/build/buildtools/bin --prefix=/it/sbx/a2c2/x86_64-linux/gcc-c/pkg --build=x86_64-pc-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.3.1 20210520 (for GNAT Community 2021 20210519) (GCC) 

@Lucretia

coffeebe4code commented 3 years ago

any idea? Still unable to generate sdlada, and there is no binary distributed anywhere.

Lucretia commented 3 years ago

No, because it should work, it's assigning a constant access variable to another in the creation of a new iterator from an iterator of the same type. You could try gcc 11 to see if it's a bug in gcc 10, I currently only have gcc 9.3.0 built. Or try replacing:

   overriding
   function First (Object : Iterator) return Cursor is
   begin
      --  Put_Line ("First -> Index = " & Natural'Image (Object.Index));

      return Cursor'(Container => Object.Container,
                     Index     => Object.Index,
                     Current   => Object.Container.Data.Colours);
   end First;

With:

   overriding
   function First (Object : Iterator) return Cursor is
   begin
      --  Put_Line ("First -> Index = " & Natural'Image (Object.Index));

      return C : Cursor do
         C.Container := Object.Container;
         C.Index     := Object.Index;
         C.Current   := Object.Container.Data.Colours;
      end return;
   end First;

And see if that works.

Lucretia commented 3 years ago

Did this work?

xyproto commented 3 years ago

I get the same error.

gcc (GCC) 11.1.0 on Arch Linux on 64-bit x86, using latest master (997d2ae2da5c75e2ea99cee98372cf5b752519cf).

gprbuild -p -gnat2012 -XSDL_MODE=release -XSDL_PLATFORM=linux -Ptools.gpr
Setup
[mkdir]        object directory for project Tools
Compile
[Ada]          gen_keyboard.adb
[Ada]          scancodes.ads
[Ada]          utils.adb
Bind
[gprbind]      gen_keyboard.bexch
[Ada]          gen_keyboard.ali
Link
[link]         gen_keyboard.adb
./gen/release/tools/gen_keyboard > gen/src/sdl-events-keyboards.ads
gprbuild -p -gnat2012 -XSDL_MODE=release -XSDL_PLATFORM=linux \
-Psdlada.gpr
Setup
[mkdir]        object directory for project SDLAda
Compile
[C]            version_ttf.c
[C]            version_images.c
[C]            version.c
[Ada]          sdl-ttfs.adb
[Ada]          sdl-ttfs-versions.adb
[Ada]          sdl-ttfs-makers.adb
[Ada]          sdl-images.adb
[Ada]          sdl-images-versions.adb
[Ada]          sdl-images-io.adb
[Ada]          sdl.adb
[Ada]          sdl-video.adb
[Ada]          sdl-video-windows.adb
[Ada]          sdl-video-windows-manager.adb
[Ada]          sdl-video-windows-makers.adb
[Ada]          sdl-video-textures.adb
[Ada]          sdl-video-textures-makers.adb
[Ada]          sdl-video-surfaces.adb
sdl-video-surfaces.ads:212:57: warning: aggregate not fully initialized
[Ada]          sdl-video-surfaces-makers.adb
[Ada]          sdl-video-renderers.adb
[Ada]          sdl-video-renderers-makers.adb
[Ada]          sdl-video-rectangles.adb
[Ada]          sdl-video-pixels.ads
[Ada]          sdl-video-pixel_formats.adb
[Ada]          sdl-video-palettes.adb
sdl-video-palettes.adb:146:41: expected type "Palette_Constant_Access" defined at sdl-video-palettes.ads:124
sdl-video-palettes.adb:146:41: found type access to "Palette'CLASS" defined at line 69
sdl-video-palettes.adb:163:41: expected type "Palette_Constant_Access" defined at sdl-video-palettes.ads:124
sdl-video-palettes.adb:163:41: found type access to "Palette'CLASS" defined at line 69
gprbuild: *** compilation phase failed
make: *** [makefile:48: lib/libadasdl.a] Error 4
xyproto commented 3 years ago

The patch proposed above does not work here. After applying the changes, I still get:

sdl-video-palettes.adb:146:31: expected type "Palette_Constant_Access" defined at sdl-video-palettes.ads:124
sdl-video-palettes.adb:146:31: found type access to "Palette'CLASS" defined at line 69
sdl-video-palettes.adb:164:41: expected type "Palette_Constant_Access" defined at sdl-video-palettes.ads:124
sdl-video-palettes.adb:164:41: found type access to "Palette'CLASS" defined at line 69

(My goal is to get the Ada example in sdl2-examples to work again).

Lucretia commented 3 years ago

This is the same as #62

anisimkov commented 3 years ago

I get the same error.

gcc (GCC) 11.1.0 on Arch Linux on 64-bit x86, using latest master (997d2ae).

The patch #62 is working (and the same #75), I tried it on GNAT Community 2021.

simonjwright commented 3 years ago

Using 997d2ae, the sdl2-examples demo works on macOS Big Sur with FSF GCC 11.1.0 and GNAT CE 2021 (out-of-the-box, bar macOS framework linking stuff as in the example)

l4e21 commented 2 years ago

I am also having this issue (gcc (GCC) 11.1.0, Manjaro) Have attempted #62 and receive sdl-video-pixel_formats.ads:642:04: representation item must appear after type is fully defined No dice with that one.

However #75 worked just fine for me.