# \#c++api

**URL:** https://discourse.mc-stan.org/tag/c-api/9.md

[Latest](https://discourse.mc-stan.org/latest.md) · [Categories](https://discourse.mc-stan.org/categories.md) · [Tags](https://discourse.mc-stan.org/tags.md)

---

## [Sampling within another C++ program, how to construct \`var\_context\`?](https://discourse.mc-stan.org/t/sampling-within-another-c-program-how-to-construct-var-context/29351)

<div class="topic-metadata">

**Author:** [@Sam\_Watson](https://discourse.mc-stan.org/u/Sam_Watson)\
**Replies:** 4\
**Last updated:** [November 6, 2022, 1:40pm UTC](https://discourse.mc-stan.org/t/sampling-within-another-c-program-how-to-construct-var-context/29351 "2022-11-06T13:40:49Z")

</div>

I am trying to write a C++ program within which posterior samples are generated using Stan’s sampler and then those samples go on to be part of another calculation, rather than returning the samples and calling a new fun…

---

## [Use Stan easily from c++](https://discourse.mc-stan.org/t/use-stan-easily-from-c/2900)

<div class="topic-metadata">

**Author:** [@garjola](https://discourse.mc-stan.org/u/garjola)\
**Replies:** 25\
**Last updated:** [May 16, 2018, 12:09am UTC](https://discourse.mc-stan.org/t/use-stan-easily-from-c/2900 "2018-05-16T00:09:05Z")

</div>

Hi, I was wondering if there has been any progress on this question here. The idea is being able to use Stan from C++ as easily as it is from R or Python. My use case is that I am doing data acquisition and pre-process…
