Stanc could not find include file

I am trying to compile a function stored in a separate file.
The file I am trying to compile looks like this:

functions {
#include hat_ode.stan
}
model{
}

stanc returns

could not find include file: #include hat_ode.stan
Error in stanc(file = "expose_ode.stan") :
  failed to parse Stan model 'expose_ode' due to the above error.

I’ve followed @bgoodri advice from a nother thread - flush left, no trailing whitespace - without any luck.

In addition, I have tried specifying the include file name as ./hat_ode.stan and also with it’s full path.

list.files() confirms that the main program file and hat_ode.stan are in the directory that I am running R in.

I have R version 3.4.4 and rstan 2.17.3

How are you calling it from R?

ff <- stanc("expose_ode.stan")

Everything looks right, so it is probably just some typo. If you post the whole thing, I can try to compile it.

Very simple, failing example attached, main stan program and file containing function are both in the directory in which R is being run:

myfunc.stan (56 Bytes)
mymain.stan (46 Bytes)

attempted compilation:

ff <- stanc("mymain.stan")
could not find include file: #include myfunc.stan
Error in stanc("mymain.stan") :
  failed to parse Stan model 'mymain' due to the above error.

Thanks for taking a look at this. I’m stumped.

It works for me if I change the line to

#include /myfunc.stan

There may be some inconsistency as to whether the trailing slash in the searched directory is included or excluded.

Thanks @bgoodri. That’s fixed it.