Bugs with strcat, and with comments

Hi Rooters, I’m using the latest production release on Win XP.

Here is my very simple code, it crashes CINT when executing the last line (the strcat instruction).
Is there any reason, and any fix for it ?

{
gROOT->Reset();
int Nsets=3;
double w[Nsets]; // pedestrian speed array (m/s)
char nom[250],moy[10];
sprintf(moy,"%f",10.22);
strcpy(nom,"exp([0]+[1]
(x-");
printf("%s, %s\n",moy,nom);
strcat(nom,moy);
}

Then, If I simply add a comment, like /**/ in the first line, above the bracket, and then interpret it in CINT, I get an error message:

Processing E:\Analyse\Progfinaux_122004\test.C…
Error: Non-static-const variable in array dimension FILE:E:\Analyse\Progfinaux_122004\test.C LINE:5
(cint allows this only in interactive command and special form macro which
is special extension. It is not allowed in source code. Please ignore
subsequent errors.)
*** Interpreter error recovered ***

What is this mystery ? Comments are not interpreted as comments ?

Thanks for your help…

Hi,

On windows XP with MS VC 7.1 and root 4.01/05 and cint 5.15.159, I can not reproduce neither of your problems :frowning:

The only guess I have, is to recommend increase the size of the array moy.

Cheers,
Philippe.

Thanks for your reply.
I’m using Win XP, Root 4.01/01 and CINT 5.15.146
I should try the same test after udating to the same version than yours.
I will let you know If I try.
Regards.

Hello,

The comment at the beginning is significant for unnamed macro. You migt already know , but ROOT/CINT has 2 modes for scripting.

  1. C++ script : this is basically same as C++ program
  2. unnamed macro : this is a sequence of C++ statements in global scope. Unnamed macro has to begin with ‘{’ and end with ‘}’.
    ROOT/CINT automatically judges between C++ script and unnamed macro. For that purpose, comment at the beginning of the file is significant.

Thank you
Masa Goto