planetis-m / naylib

Yet another raylib Nim wrapper
MIT License
181 stars 10 forks source link

Error running the bunnymark example #89

Closed distantforest1 closed 9 months ago

distantforest1 commented 9 months ago

Hello I'm trying to run the bunnymark example from here: https://github.com/planetis-m/raylib-examples/blob/main/textures/bunnymark.nim

However I'm getting an issue where it errors with this message:

C:\Users\winuser\.nimble\pkgs2\naylib-4.6.1-b8dba6d8ec2d85d03665077430f315612b508f4c\raylib\src/raylib.h:1237:13: 
error: conflicting types for 'LoadImageA'; have 'Image(const char *)'
 1237 | RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM)

How would I fix this?

Here is the full error message if you'd like to take a look at the full thing:

bunnymarkerror.txt

distantforest1 commented 9 months ago

Hi I've broken it down further and created a basic repro of the issue:

import raylib, raymath

type
  Player = ref object
    name: string
    position: raylib.Vector2 = Vector2.zero # Removing the vector also removes the error

proc main =
  var players = newSeq[Player](1)

  players[0] = Player()
  players[0].position = Vector2()
  players.add(Player()) # <<<< This gives the error

  # vvvv Adding this way doesn't give the error vvvv
  players.setLen(3)
  players[2] = Player()

main()
# Error:
# C:\Users\winuser\.nimble\pkgs2\naylib-4.6.1-b8dba6d8ec2d85d03665077430f315612b508f4c\raylib\src/raylib.h:1237:13: error: conflicting types for 'LoadImageA'; have 'Image(const char *)' 1237 | RLAPI Image LoadImage(const char *fileName);  // Load image from file into CPU memory (RAM)`
planetis-m commented 9 months ago

Strange that two functions with different names (LoadImage vs LoadImageA) have conflicts. We will have to mangle these as well.