tomhrr / dale

Lisp-flavoured C
BSD 3-Clause "New" or "Revised" License
1.02k stars 48 forks source link

Parsing header files containing undefined functions #178

Closed porky11 closed 6 years ago

porky11 commented 7 years ago

When a c library doesn't contain all functions, that are declared in the headef file, it is no problem, if they are declared in dale as extern-c anyway. But if I define a wrapper around this undefined function, it won't compile anymore, because the function is not defined.

(import stdlib)

(def x (fn extern-c void (void))) ;;unused undeclared function

(def X (fn (attr inline) extern void (void) ;;wrapper function, without this, the program works
  (x)))

(def main (fn extern-c void (void)
  (printf "no problem\n")))
tomhrr commented 6 years ago

This is intentional, and C has analogous behaviour. When x is unused, it doesn't matter that there isn't a definition for it, but once it is used, it must be defined, even if the use site itself is not used.