Include a C++ function in a Stan code

Dear all,
I need to include a C++ function in a stan code but I don’t know how I can do it.

The function is remainder and then I include the associated library but I get this error:

SystemError: opening file "<cmath>": No such file or directory

Here a draft:

stancode = "functions {
   real[] P_growth(real t,       // time
                   real[] x,      // state
                   real[] theta, // parameters
                   real[] x_r,   // environmental data
                   int[] x_i){
    real gamma  = theta[1];
    real lambda = theta[2];

    real growth = gamma*x[1];

    #include <cmath>
    if (remainder(t,24) < 14) {
        real loss   = lambda*x[1]*x[1];
    } else {
        real loss   = 0;
    }
    
    
    return {growth - loss};
  }
}
data {
    int<lower = 0> N;           // num obs
    real t_obs[N];              // obs times
    real<lower = 0> y[N];       // observed variable at measurement times
    real sigma;
}
parameters {
    real<lower=0,upper=1> theta[2];      // parameters
    real<lower=0> x0[1];
}
transformed parameters {
    real x[N,1] = integrate_ode_rk45(P_growth, x0, -1, t_obs, theta,
                                      rep_array(0.0, 0), rep_array(0, 0),
                                      1e-6, 1e-5, 1e3);
}
model {
    //theta[1] ~ normal(0.1, 2);
    //theta[2] ~ normal(0.1, 2);
    x0       ~ normal(1.0, 10);
    y[1:N]   ~ normal(x[1:N,1], sigma); // obs
}";

Thanks a lot.

Not sure if this is helpful: Interfacing with External C++ Code

If that doesn’t help probably our best bet is Stan discourse or to ask Bob C directly.

Many thanks @goedman, I tried with your link but it still not working! I wrote on Stan discourse!