Cannot run a root macro with user-defined class

Dear Rooters

I tried to convert my analysis code to a Root macro. The problem is that my code includes a class I defined and implemented in separate files. When I run “root .x .cc”, the error message is

In file included from input_line_9:1:
/Ramiel/My Document/Work/KMUTT Work/LI/Z-Adjustment/RootMacro/ error: expected ‘;’ after top level declarator
int Z-Adjustment_alphaRoot()

What could be the problem?

ps I tried to search the forum for similar problems and could not find any.
My Root version is 6.04.
I am running on Mac OS X 10.8.5

Please help,
Kachanon (1.25 KB)
StudentMark.h (908 Bytes) (12.8 KB)


the first thing would be to avoid invalid function names, like the ones containing “-”, e.g. “Z-Adjustment_alphaRoot” should be “Z_Adjustment_alphaRoot”.
Then what you can do is the following from the root prompt:

root[0] .L
root[1] .x

I attached the modified files because of the name change mentioned above and some missing include guards.

StudentMark.h (964 Bytes) (12.8 KB) (1.25 KB)


Thank you very much for your help. I followed your suggestion and it produced an error I do not understand. The error message is:

root [0] .L
Info in TMacOSXSystem::ACLiC: creating shared library /Ramiel/My Document/Work/KMUTT Work/LI/Z-Adjustment/RootMacro/./
clang: warning: unknown warning option ‘-Wheader-guard’; did you mean ‘-Wheader-hygiene’?
warning: unknown warning option ‘-Wheader-guard’; did you mean
’-Wheader-hygiene’? [-Wunknown-warning-option]
1 warning generated.
root [1] .x
root.exe(1077,0x7fff7a554180) malloc: *** mmap(size=140377062785024) failed (error code=12)
*** error: can’t allocate region
*** set a breakpoint in malloc_error_break to debug
libc++abi.dylib: terminate called throwing an exception


Hi Kachanon,

this looks weird:I cannot reproduce the issue.
How did you install root (from sources, binaries)? What version of OSx you are running on?
Did you modify the file and if yes, could you repost it?



I installed Root using command “tar -xzf root_v6.04.02.macosx64-10.8-clang51.tar.gz” o the binary-version file I downloaded from .

In my .bash_profile, I have
export ROOTSYS=$HOME/root
export PATH=$PATH:$ROOTSYS/bin

My OS X version is 10.8.5 .

I didn’t modify any files you give me. I attach the three C++ files and also the input txt file just in case.

Data.txt (7.63 KB) (1.23 KB)
StudentMark.h (933 Bytes) (12.9 KB)


After running “.L” and .x the macro again, it seems to work. Unfortunately, it doesn’t like my end-of-file checking. Somehow, it returns segmentation violation after it meet the end of the file. I am working on this issue. If I manage to fix it, I will let you know. If you have any suggestions, please give them to me.



After deleting the blank line at the end of the input file, everything works properly. Problem’s solved!

Thanks a lot for the help,
Kachanon Nirunpong