You do not have to put functions into the same file in Common Lisp for them to be in the same compilation unit.
Doing this is an anti-pattern; large programs are, of course, constructed from modules, most of which call functions that are in another module. You cannot roll an entire program into a single physical module to avoid a warning about this.
Lisp has a mechanism by which a cluster of compiles is regarded as a single compilation unit: the with-compilation-unit
macro:
(with-compilation-unit
(compile-file "file-f")
(compile-file "file-f2"))
If you use the ASDF build system, I seem to recall it does the with-compilation-unit
under the hood for you, around all of the files of a system.
This approach will help eliminate those warnings which are deferred. That is to say, if the implementation warns about undefined identifiers, but defers doing so until the end of the compilation unit, then if you use this macro, the deferral is extended until the end of the total compilation unit spanning multiple files.
When warnings about undefined identifiers are deferred, the purpose is to eliminate those warnings. If the definition of a previously undefined function appears before the end of a translation unit, the warning can be suppressed. This macro allows a definition in one file to suppress a deferred warning in another file.
If an implementation doesn't defer warnings, then the macro will not help.