Skarsnik / sneshacking

Various romhacking stuff
16 stars 2 forks source link

Compile error on testpng.c, using GCC11 #14

Open IoIxD opened 2 years ago

IoIxD commented 2 years ago

I'm sure there's something on my part that's wrong but I have tried for the entire day to compile this and I just can't. Using GCC 11.2.0 but I've also tried GCC] 6, and 5. Nothing seems to work, and I always get the same errors regarding tilepng.c.

gavin@jeff ~/S/s/src (master)> cmake .
CMake Warning (dev) in CMakeLists.txt:
  No project() command is present.  The top-level CMakeLists.txt file must
  contain a literal, direct call to the project() command.  Add a line of
  code such as

    project(ProjectName)

  near the top of the file, but after cmake_minimum_required().

  CMake is pretending there is a "project(Project)" command on the first
  line.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- The C compiler identification is GNU 11.2.0
-- The CXX compiler identification is GNU 11.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/sbin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/sbin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Found ZLIB: /usr/local/lib/libz.a (found version "1.2.2.3") 
-- Found PNG: /usr/lib/libpng.so (found version "1.6.37") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/gavin/Sources/sneshacking/src
gavin@jeff ~/S/s/src (master)> make 
[ 20%] Building C object CMakeFiles/testexportpng.dir/testpng.c.o
In file included from /home/gavin/Sources/sneshacking/src/testpng.c:6:
/home/gavin/Sources/sneshacking/src/tilepng.h:7:46: error: unknown type name ‘palette’
    7 | void export_tile_to_png(tile8 rawtile, const palette pal, const char* filename);
      |                                              ^~~~~~~
/home/gavin/Sources/sneshacking/src/testpng.c: In function ‘main’:
/home/gavin/Sources/sneshacking/src/testpng.c:23:3: error: unknown type name ‘palette’; did you mean ‘r_palette’?
   23 |   palette* pal = palette_create(8, 0);
      |   ^~~~~~~
      |   r_palette
/home/gavin/Sources/sneshacking/src/testpng.c:23:18: error: initialization of ‘int *’ from incompatible pointer type ‘r_palette *’ [-Werror=incompatible-pointer-types]
   23 |   palette* pal = palette_create(8, 0);
      |                  ^~~~~~~~~~~~~~
/home/gavin/Sources/sneshacking/src/testpng.c:27:8: error: request for member ‘colors’ in something not a structure or union
   27 |     pal->colors[i].red = i * 30;
      |        ^~
/home/gavin/Sources/sneshacking/src/testpng.c:28:8: error: request for member ‘colors’ in something not a structure or union
   28 |     pal->colors[i].blue = i * 30;
      |        ^~
/home/gavin/Sources/sneshacking/src/testpng.c:29:8: error: request for member ‘colors’ in something not a structure or union
   29 |     pal->colors[i].green = i * 30;
      |        ^~
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/testexportpng.dir/build.make:76: CMakeFiles/testexportpng.dir/testpng.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/testexportpng.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
gavin@jeff ~/S/s/src (master) [2]> 
IoIxD commented 2 years ago

I had to change tilepng.c, tilepng.h, testpng.c, and CMakeLists.txt to get it to compile. How this was last compiled a year ago and was never caught is beyond me.

Not gonna bother making a new repo for a pull requests, I'll just put the files here

tilepng_c.txt testpng_c.txt tilepng_h.txt CMakeLists.txt

(edit: I actually ended up making a fork of the repo anyways for various other reasons)

Skarsnik commented 2 years ago

I totatly forget to update this when I changed the palette code. I will maybe have a look

Skarsnik commented 2 years ago

Should be fixed as it compiles, but it segfault now x)