tomhrr / dale

Lisp-flavoured C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug with global variable initializer

ChengCat opened this issue · comments

(def X (struct extern ((a (p void)))))

(def make-x (fn extern X (void)
  (def tmp (var auto X))
  tmp))

(def var-x (var extern X (make-x)))

With the above program, the compiler complains about:

error: unable to resolve pointer address in struct declaration

Sorry, this is actually a sound behaviour. The program compiles fine if changed to:

(def X (struct extern ((a (p void)))))

(def make-x (fn extern X (void)
  (def tmp (var auto X))
  (setf (: tmp a) (nullptr void))
  tmp))

(def var-x (var extern X (make-x)))