Revision 6542fdbd8d000fc5b18eb3f396b5d18f1ffd6521 authored by Paul Russo on 13 June 2008, 20:34:11 UTC, committed by Paul Russo on 13 June 2008, 20:34:11 UTC
"int" so that NULL translates to a constant integral type.

The C++ standard has this to say in section
4.10 Pointer conversions [conv.ptr]:

     A "null pointer constant" is an integral constant
     expression (5.19) rvalue of integer type that
     evaluates to zero.

This is a problem in a function overloading situation
like this:

void f(double);
void f(char*);

int main()
{
   for (int i = 1; i < 10; ++i) {
      f(i);
   }
}

The rule in section 4.10 on null pointer constants
and the rules in Chapter 13 Overloading, make f(char*)
a non-viable function for overloading purposes
because i is not a "integral constant expression".

However given:

     #define POGO 0

then in the same loop a call written:

     f(POGO);

is ambiguous since both of the functions are viable
(because POGO is substituted with 0, which is an
integral constant expression).

In cint "#define int MyType" is implemented as a variable
definition using the special type macroInt$.  So we need
to make that type const so that overloading works correctly.

Note that this is all a gross hack to paper over the fact
that cint does not have a proper preprocessor.

-- Paul Russo and Philippe Canal


git-svn-id: http://root.cern.ch/svn/root/trunk@24273 27541ba8-7e3a-0410-8455-c3a389f83636
1 parent 81bd3c4
Raw File
rootalias.C

//______________________________________________________________________________
void edit(char *file)
{
   char s[64], *e;
   if (!strcmp(gSystem->GetName(), "WinNT")) {
      if (e = getenv("EDITOR"))
         sprintf(s, "start %s %s", e, file);
      else
         sprintf(s, "start notepad %s", file);
   } else {
      if (e = getenv("EDITOR"))
         sprintf(s, "%s %s", e, file);
      else
         sprintf(s, "xterm -e vi %s &", file);
   }
   gSystem->Exec(s);
}

//______________________________________________________________________________
void ls(char *path=0)
{
   char s[256] = (!strcmp(gSystem->GetName(), "WinNT")) ? "dir /w " : "ls ";
   if (path) strcat(s,path);
   gSystem->Exec(s);
}

//______________________________________________________________________________
void dir(char *path=0)
{
   char s[256] = (!strcmp(gSystem->GetName(), "WinNT")) ? "dir " : "ls -l ";
   if (path) strcat(s,path);
   gSystem->Exec(s);
}

//______________________________________________________________________________
char *pwd()
{
    return gSystem->WorkingDirectory();
}

//______________________________________________________________________________
char *cd(char *path=0)
{
 if (path)
   gSystem->ChangeDirectory(path);
 return pwd();
}

//______________________________________________________________________________
void bexec2(char *macro)
{
printf("in bexec dir=%s\n",dir.Data());
   if (gROOT->IsBatch()) printf("Processing benchmark: %s\n",macro);
   TPaveText *summary = (TPaveText*)bench->GetPrimitive("TPave");
   TText *tmacro = summary->GetLineWith(macro);
   if (tmacro) tmacro->SetTextColor(4);
   bench->Modified(); bench->Update();

   gROOT->Macro(macro);

   TPaveText *summary2 = (TPaveText*)bench->GetPrimitive("TPave");
   TText *tmacro2 = summary2->GetLineWith(macro);
   if (tmacro2) tmacro2->SetTextColor(2);
   bench->Modified(); bench->Update();
}
back to top