Do you encounter the issues also when not knitting?
Rtools 4.0 imply you have R 4.0, so this might be relevant
A bunch of people had similar errors, so you might want to try what worked for them:
https://discourse.mc-stan.org/search?q=ISO%20C%2B%2B11%20requires%20whitespace%20after%20the%20macro%20name
If that doesn’t help, feel free to get back here and ask some more!