That's a frequent question. Probably already answered on Stackoverflow.
- during compilation, the code of functions is generated, but not loaded into the compiler.
- macros OTOH are also made available in the compile-time environment
Two solutions:
separate files: one which defines macros and the needed functions, another one where the macros are being used. Load the macro and its support code, before compiling dependent files.
use
EVAL-WHEN
with:load-toplevel
,:compile-toplevel
and:execute
around the functions which are needed at compile-time.:compile-toplevel
makes sure than any enclosed top-level code gets executed during compilation - for adefun
this would define the function at compile-time, too.
See: http://www.lispworks.com/documentation/HyperSpec/Body/s_eval_w.htm#eval-when
Note, that you don't need two evals in your example. You can also write --eval "(progn (load ...) (compile-file ...))
or even --eval "(let ((file ...)) (load file) (compile-file file))
.