In situations where the same function is referenced in multiple files, ferret code generation can result in the function definitions being included multiple times. In the following example the bar function is called directly in main, and also indirectly via the foo function:
main.clj:
(require 'foo)
(require 'bar)
(foo/foo)
(bar/bar 0)
foo.clj:
(require 'bar)
(defn foo []
(bar/bar 1))
bar.clj
If you compile main.clj with ferret, it will emit a .cpp file with multiple definitions of the bar function. Trying to compile that .cpp file will result in these errors:
src/main.cpp:2537:7: error: redefinition of 'class main::bar_bar'
class bar_bar {
^~~~~~~
src/main.cpp:2527:7: note: previous definition of 'class main::bar_bar'
class bar_bar {
^~~~~~~
src/main.cpp:2564:12: error: redefinition of 'ferret::var main::bar_bar::invoke(ferret::ref) const'
inline var bar_bar::invoke(ref _args_) const {
^~~~~~~
src/main.cpp:2551:12: note: 'ferret::var main::bar_bar::invoke(ferret::ref) const' previously defined here
inline var bar_bar::invoke(ref _args_) const {
^~~~~~~
In situations where the same function is referenced in multiple files, ferret code generation can result in the function definitions being included multiple times. In the following example the
barfunction is called directly inmain, and also indirectly via thefoofunction:main.clj:
foo.clj:
bar.clj
If you compile main.clj with ferret, it will emit a .cpp file with multiple definitions of the
barfunction. Trying to compile that .cpp file will result in these errors: