Error using macro on root

I am using ROOT 6.18/02 on Windows 10 with Visual Studio 2019.

I have a macro file formula1.C with the following lines of code:

{
f = new TF1(“f”,“sin(x)”,0,5);
f->Draw();
}

When I run .x formula1.C in ROOT, I get the following error:

Assertion failed: content[posOpenCurly] == ‘{’ && “No curly at claimed position of opening curly!”, file C:\build\ws\BUILDTYPE\Release\LABEL\windows10\V\6-18\root\interpreter\cling\lib\MetaProcessor\MetaProcessor.cpp, line 431

Thereafter ROOT exits.

What is wrong here?

Try to use a named macro containing a function being the same name than the file name:

void formula1()
{
   auto f = new TF1("f","sin(x)",0,5);
   f->Draw();
}

That worked like a charm. Thanks!

1 Like