Misleading missing brace error and its consequences

Hello,

I have been working for some time on a script to simulate the propagation of a dilute beam of atoms from from the source through 4 laser beams and then towards an optical cavity.

The script was working, but after I added new features to it, it stopped doing so (new features : gaussian beam correction). Now whenever I execute it I get the following.

After browsing through the script, which really isn’t that long, puzzled, I did a brute force count using grep:

grep -c '{' lvis_opt_mol.C 
22
grep -c '}' lvis_opt_mol.C 
22

I know that this only counts the number of lines where it finds hits, but I have used the search function of my text editor (gedit) and I have found the same number.

I decided to give up and add an extra brace at the end:

grep -c '{' lvis_opt_mol.C 
22
grep -c '}' lvis_opt_mol.C 
23

But then I got this error:

Now I’m even more confused. Is there a limit on the size of the scripts as can be run by CINT?
The line where the “limitation” occurs never had problems in the past.
I’ve spent a lot of time on this. Perhaps someone else could point out the “obvious” to me!

Thank you
lvis_opt_mol.C (12.2 KB)

Hi,

to compile your macro header file “definitions.h” is needed…

One possible debugging aproach in your case is to comment out the whole body of your lvis_opt_mol() function, check whether it compiles (it does) and then start to uncomment blocks of the code from top to bottom and everytime check whether you are still able to compile your script or not. You should sooner or later see where the problem is…

Hope that helps you.

Cheers,
Jiri

I’ve uploaded the header file.

I’ll try your suggestion.

Thanks
definitions.h (4.57 KB)

Success, I found the problem…it was a missing parenthesis…

I’ll go now and die of incompetence…

…if this makes you feel better, I got the same cint error what you had second time, without any indications of a missing brace…
if you do not post this error message, i guess finding the source of this problem would have take me ages, which i did not have now. I did not expect syntax…
so thanks a lot! :mrgreen: anna

Hello,

Two general comments:

  1. Compiling your macro not only finds problems like this, it makes it less likely that “weird” things happen. Compiling is good.

  2. With emacs (as well as I’m sure other editors), they can be useful in helping to tell you that you’re missing a ‘)’ or a ‘}’.

Cheers,
Charles

[quote=“ann”]…if this makes you feel better, I got the same cint error what you had second time, without any indications of a missing brace…
if you do not post this error message, i guess finding the source of this problem would have take me ages, which i did not have now. I did not expect syntax…
so thanks a lot! :mrgreen: anna[/quote]

Well that does make me feel a bit better, thanks! and good luck!

… yes, this was the point when I stopped being lazy, wrote a proper makefile, and compiled my code :frowning:
just running the macro directly seemed to be a comfortable solution for a beginner like me (also suggested b the user’s guide), until I started to work on a real problem.
then i found the root-config command so doing the makefile was not horrible at all (which i expected at first)
now everything compiles and runs nicely :slight_smile:

Note that you do not need to write a makefile. If you have a script.C

root >.x script.C executes via the interpreter root > .x script.C+ the script is compiled via CINT/ACLIC using the native compiler (gcc) and executed see Users Guide for more details