Closed andrjohns closed 1 month ago
Hm, this is an interesting edge case. It does seem like if you’re doing this, you’re doing something pretty weird, because you could just call your own header. If I was going to “fix” this I think they way I would want to do it is actually by just not emitting a definition at all in this case
An 'easy' fix could be to just emit the declaration for any undefined functions when standalone-functions is called. So the make_odds
generation could just be:
// [[stan::function]]
double make_odds(const double& theta, std::ostream* pstream__);
Would that work?
That would break the compile of someone who needed their own forward decl, I think. For example, if make odds was recursive
It also would probably be an issue that the user header is included before the stanc generated code
Ah true. Yeah I'll just handle this internally in cmdstanr
then
When calling
--standalone-functions
with undefined/external-c++, the generated functions expect the function definitions to be within the model namespace.For example, with the make_odds example, the generated
.hpp
is:Compiling the generated hpp and including the user header fails, as the
make_odds
function wasn't declared in a namespace in the external user header.This is a bit of an edge-case, so feel free to let me know if it would be more effort than it's worth to fix, and I can just workaround it in
cmdstanr