# Root gives an error for this macro but it runs fine in codeblocks

**URL:** <https://root-forum.cern.ch/t/root-gives-an-error-for-this-macro-but-it-runs-fine-in-codeblocks/39464>\
**Category:** Newbie\
**Created:** [May 18, 2020, 1:19am UTC](https://root-forum.cern.ch/t/root-gives-an-error-for-this-macro-but-it-runs-fine-in-codeblocks/39464 "2020-05-18T01:19:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hep\_1](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/hep_1/32/21930_2.png) [@hep\_1](https://root-forum.cern.ch/u/hep_1)\
**Post date:** [May 18, 2020, 1:19am UTC](https://root-forum.cern.ch/t/root-gives-an-error-for-this-macro-but-it-runs-fine-in-codeblocks/39464/1 "2020-05-18T01:19:31Z")

</div>

The code I have attached is just something I wrote in codeblocks, and it runs fine there. I thought to check if I can run it in root too (and I assumed that it should work), but when I try to run it, root gives the error:

> cannot open file “random” montecarlo1.cpp:4:  
> \*\*\* Interpreter error recovered \*\*\*

Can someone see why I am getting the error and how I can resolve it? The code is attached.

[montecarlo1.cpp](https://root-forum.cern.ch/uploads/short-url/8D9RRAPwFEoNEXRpbnb7YSoLu8c.cpp) (1.5 KB)

_ROOT Version:_ 5.34/38  
_Platform:_ Ubuntu  
_Compiler:_ Not Provided

* * *

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [May 18, 2020, 8:25am UTC](https://root-forum.cern.ch/t/root-gives-an-error-for-this-macro-but-it-runs-fine-in-codeblocks/39464/2 "2020-05-18T08:25:13Z")

</div>

There is no ROOT involved.

BTW. “[random](http://www.cplusplus.com/reference/random/)” needs at least C++11. Also, rename “function” into something else (you have a name clash with the standard C++ “`template<typename _Signature> class function;`”).

---

<div class="post-metadata">

**Author:** ![hep\_1](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/hep_1/32/21930_2.png) [@hep\_1](https://root-forum.cern.ch/u/hep_1)\
**Post date:** [May 18, 2020, 3:28pm UTC](https://root-forum.cern.ch/t/root-gives-an-error-for-this-macro-but-it-runs-fine-in-codeblocks/39464/3 "2020-05-18T15:28:35Z")

</div>

Yes, there is no ROOT involved. Just wondering if it did not run because I am using an older ROOT version. Could it be possible? Cause I was under the impression that any cpp file can be used as a macro and can be run in root. Is it not true?
