microsoft / knossos-ksc

Compiler with automatic differentiation
Other
45 stars 10 forks source link

Add #includes to generated C++ #1000

Closed dcrc2 closed 2 years ago

dcrc2 commented 2 years ago

Adds an option --cpp-include to ksc, to specify files to #include at the top of the generated code.

This makes it possible for ksc to generate a self-contained C++ file. Previously if a prelude was used which defined edefs, it was not possible to compile the resulting C++ without modifying it to add the corresponding #include.

I've removed the inclusion of prelude.h at the bottom of knossos.h. This means that you now have to specify --cpp-include prelude.h explicitly. The advantage is that it becomes possible to provide other implementations of the prelude, e.g. for CUDA support.