Porting ROOT Macros from ROOT 5 to ROOT 6

Overview

In ROOT6, (CMSSW_7_4_X and CMSSW_7_5_X) ROOT macros are processed with cling, rather than CINT. cling is much less permissive. To oversimplify just a bit, cling requires valid C++ with just a few ROOT specific extensions. As a result, of the approximately 800 macros (files ending in .C) in CMSSW, over 500 of them appear to not compile in ROOT 6.

Some of your macros may be among them. If your macros are important, you may want to check that they still work.

Compilation Errors and Possible Fixes

This is a partial listing of possible macro compilation errors with cling (ROOT6), with possible fixes. It is not definitive, and not final.

compilation error message // Possible fixes

The most common error message

use of undeclared identifier 'XXX' // This is by far the most common error message. There are many different causes.

Cause 1: A function defined in a file is called in the same file before the definition // Recommended fix: Add function declaration near the beginning of the file. // Alternate fix: Reorder the file.

Cause 2: A function defined in one file is called from a different file, which has no declaration // Fix: Add function declaration, using "extern" keyword, near the beginning of the calling file. // Note: This should fix the compilation error, but there may still be link errors. // You might need to add a #include, or a ProcessLine() or a LoadMacro(). Consult a ROOT expert if needed.

Cause 3: A variable declared inside curly braces is used outside the braces. // Fix: move the declaration outside the braces. // Alternate fix: Move all the usage inside the braces.

Other Causes: Beyond the scope of this document. Consult experts if you can't fix it.

Other error messages

'aaa' is a (private | protected) member of 'XXX' // Use a public accessor function for aaa. Add it to XXX if needed,

'iostream.h' file not found // Replace iostream.h with iostream

'vector.h' file not found // Replace vector.h with vector

'XXX.C' file not found with <angled> include; use "quotes" instead // Replace <XXX.C> with "XXX.C"

C++ requires a type specifier for all declarations // Specify return type for function (e.g. void, int. ...)

assigning to 'XXX *' from incompatible type 'XXX' // The cases I fixed had a missing subscript on the left hand operand, which was a C-style array. Your case may differ

calling a private constructor of class 'XXX' // The cases I fixed used "XXX x = new XXX()" instead of the correct "XXX *x = new XXX()". XXX was not copyable.

cannot initialize a (variable | parameter | member subobject) of type 'Derived *' with an (lvalue | rvalue) of type 'Base *' // use dynamic_cast<Derived *>

cannot initialize a (variable | parameter | member subobject) of type 'XXX *' with an (lvalue | rvalue) of type 'const XXX *' // replace XXX * with const XXX *

cannot initialize a (variable | parameter | member subobject) of type 'XXX *' with an rvalue of type 'XXX' // The cases I fixed tried to assign a bool * to false, which is a bool.

expected unqualified-id // The cases I fixed had a comment before an unnamed macro. Move the comment(s) inside the macro.

invalid operands to binary expression ('XXX *' and 'XXX') // The cases I fixed had a missing subscript on the left hand operand, which was a C-style array. Your case may differ

member function 'FFF' not viable: 'this' argument has type 'const XXX', but function is not marked const // Declare member function FFF() const. You may (or may not) also need a non-const version of FFF().

member reference type 'XXX' is not a pointer; maybe you meant to use '.'? // Replace "->" with "."

member reference type 'XXX *' is a pointer; maybe you meant to use '->'? // Replace "." with "->"

missing default argument on parameter 'XXX' // If a function argument has a default value, all later function arguments must also have a default value. In the cases I fixed, the later argument did have a default value, but it was the wrong type.

no matching function for call to 'FFF' // In the cases I fixed, I added an "extern" declaration of the function near the beginning of the file.

no member named 'istrstream' in namespace 'std' // Add "#include <sstream>" and replace "std::istrstream" with "std::basic_istringstream<char>"

no viable conversion from 'TString' to 'char *' // Use TString::Data(). It returns char*.

non-ASCII characters are not allowed outside of literals and identifiers // Remove extraneous non-ASCII characters

non-void function 'FFF' should return a value [-Wreturn-type] // Option 1: FFF() should always return a value of the proper type. // Option 2: FFF() can be redeclared void, if it should be void. May need to modify callers.

redefinition of 'XXX' // Option 1: Remove redefinition (replacing initialization with assignment if needed) // Option 2: (usually better) Use distinct identifier names // Option 3: Put definitions, and all their uses, inside separate scopes (curly braces)

redefinition of 'XXX' as different type of symbol // Option 1: (usually better) Use distinct identifier names // Option 2: Put definitions, and all their uses, inside separate scopes (curly braces)

use of overloaded operator '+' is ambiguous (with operand types 'TString' and 'int') // Don't concatenate an int to the end of a TString. Use a char instead of an int.

variable length array of non-POD element type 'XXX' // Use an std::vector instead of a C-style array in this case.

Complete: 1

Contacts

Review status

Reviewer/Editor and Date Comments
WilliamTanenbaum - 16 Apr 2015 adding original info
   

Responsible: ChrisDJones
Last reviewed by: Sudhir Malik- 24 January 2009

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r5 - 2015-04-17 - WilliamTanenbaum
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    CMSPublic All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback