I have two macros,

one is in the folder
in this macro I have included

which calls test1.cc. I have to put the file test1.cc in the folder

otherwise root says file does not exist.

On typing .include, I get
C:\root\include, so that is the reason for the chosen folder

Is there a way I can put the test1.cc in the folder
and root can find it.

I believe I have change the include path but I dont know how to do that. Kindly help me in this regard.


When using CompileMacro, you should update the include path using gSystem->AddIncludePath("-Ic:\\root\\macros");


Thank you very much, it worked. May I ask why two \ instead of one in defining new include path ?


got it, thank you

just one more question to this thread

in the file test1.cc, I cant include any statement like

cout<<“This is test macro which has been called by test1.C”<<endl;

as it gives me errors.

In C++ while one can call function which can also print, from the function main(), why cant we do such thing from macros. Please explain.


#include <iostream>

void test1(void)
    std::cout << "This is test macro which has been called by test1.cc" << std::endl;

Thanks but this gives me errors:

root [2] .x test1.C
Info in : unmodified script has already been compiled and loaded
Info in : it will be regenerated and reloaded!
Info in TWinNTSystem::ACLiC: creating shared library c:\root\macros\choleskynewmacros\test1_cc.dll
c:\root\macros\choleskynewmacros\test1.cc(4) : error C2039: ‘cout’ : is not a member of 'std’
c:\root\macros\choleskynewmacros\test1.cc(4) : error C2065: ‘cout’ : undeclared identifier
Error in : Compilation failed!
Error: Function test1(a) is not defined in current scope C:\root\macros\test1.C(5)
*** Interpreter error recovered ***

my two macros are
test1.C in C:\root\macros\test1.C

{ gSystem->AddIncludePath("-Ic:\root\macros\choleskynewmacros");
int a=10;


test1.cc in C:\root\macros\choleskynewmacros\test1.cc

int test1(int x)
std::cout << “This is test macro which has been called by test1.C” << std::endl;
return (x+1);

Please have a look

Gracias Gracias,

I apologize as I want to clarify it completely, kindly remove my remaining doubts

  1. why did we include <iostream.h> when it gets automatically included

  2. what exactly std::cout and std::endl doing, I mean “std::”

  3. How can we pass pointers from test1.c to test1.cc

thank you very much for helping me understand.

any gentle soul, please reply !

I tried on my own and write a macro memallot.C

int * memallot (int L)
int * mat;
mat = new int [L];
return mat;

this works fine on root prompt when I do .L memallo.C and .x memallot.C(10), it returns a memory address

but when I call it from another macro test1.C

{ gSystem->AddIncludePath("-Ic:\root\macros");
int a=10;

I get “1” back, I believe this is true or false value. Please suggest how can I get the address value of the allotted value of memory from memallot.C to test1.C

  1. nothing is automatically included by a compiler (e.g. when called by ACLiC in your examples), CINT interpreter knows some includes automatically, though - see “CINT the C++ Interpreter” chapter in ROOT User’s Guide http://root.cern.ch/drupal/content/users-guide
  1. http://www.cplusplus.com/doc/tutorial/namespaces/

  2. your “memallot.C” + “test1.C” example works fine for me

> root
  *                                         *
  *        W E L C O M E  to  R O O T       *
  *                                         *
  *   Version  5.28/00f     4 August 2011   *
  *                                         *
  *  You are welcome to visit our Web site  *
  *          http://root.cern.ch            *
  *                                         *

ROOT 5.28/00f (branches/v5-28-00-patches@40439, Aug 11 2011, 10:50:00 on linux)

CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] .x test1.C
Info in <TUnixSystem::ACLiC>: creating shared library /.../memallot_C.so
root [1] .q

Thank You very much, I did learn a lot. I wonder why my program which runs on window does not return a memory address. Thank you for supporting the community.

warm regards,


On linux this script behave as expected:

root [0] .L memallot.C+ Info in <TUnixSystem::ACLiC>: creating shared library /private/var/tmp/./memallot_C.so root [1] int a = 10; root [2] cout<<memallot(a)<<endl; 0x10290fd00

You could try: cout<<(void*)memallot(a)<<endl;


it still returns “1”. Looks like I have to move to Linux :frowning:


On windows, the following incantations works to print pointers:cout << "0x" << hex << (long)p << endl;


Thank You Phillipie, I think I will move on to linux, my professor said “geez” when I informed that I have installed root on windows. I do have a question on that, I will post on a separate thread. Thank You for patiently answering the questions.