Creating custom class between versions

Hi there,

I have a macro which runs fine on my Linux machine (running Root 6.12), but the same macro won’t run on my Windows laptop, stating multiple errors at the first few lines defining a custom class which I modified from a tutorial.

I’ve only just put Root on this device, and it always starts with multiple errors, but from the little testing I’ve done this doesn’t seem to have affected the functionality.

Is there a change between 6.12 and 6.14 that could have caused this?

class file {

public:
 Double_t t;
 Double_t v;
};

class Event: public TObject {

public:
  file f;
  ClassDef(Event,1)
};

ClassImp(Event)

Error:

In file included from input_line_19:1:
In file included from \\[filepath]\root\R1R2_3.0.1.C:28:
C:\root_v6.14.00\include\ROOT/TDataFrame.hxx:20:2: warning: The TDataFrame.hxx header has been replaced by RDataFrame.hxx [-W#warnings]
#warning The TDataFrame.hxx header has been replaced by RDataFrame.hxx
 ^
In file included from input_line_19:1:
\\[filepath]\root\R1R2_3.0.1.C:44:18: error: expected parameter declarator
  ClassDef(Event,1)
                 ^
\\[filepath]\root\R1R2_3.0.1.C:44:18: error: expected ')'
\\[filepath]\root\R1R2_3.0.1.C:44:3: note: to match this '('
  ClassDef(Event,1)
  ^
libCore dictionary payload:205:17: note: expanded from macro 'ClassDef'
_ClassDefInterp_(name,id,virtual,) \
                ^
In file included from input_line_19:1:
\\[filepath]\root\R1R2_3.0.1.C:44:3: error: C++ requires a type specifier for all declarations
  ClassDef(Event,1)
  ^
libCore dictionary payload:204:28: note: expanded from macro 'ClassDef'
#define ClassDef(name, id) \
                           ^
In file included from input_line_19:1:
\\[filepath]\root\R1R2_3.0.1.C:44:3: error: expected ';' at end of declaration list
libCore dictionary payload:205:36: note: expanded from macro 'ClassDef'
_ClassDefInterp_(name,id,virtual,) \
                                   ^
In file included from input_line_19:1:
\\[filepath]\root\R1R2_3.0.1.C:70:10: error: no matching constructor for initialization of 'std::ofstream' (aka 'basic_ofstream<char,
      char_traits<char> >')
ofstream textmaker;
         ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\fstream:1011:12: note: candidate constructor template not viable: requires at least argument '_Path', but no arguments were
      provided
                explicit basic_ofstream(const _Identity_t<_Path_ish>& _Path,
                         ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\fstream:1029:11: note: candidate constructor not viable: requires single argument '_File', but no arguments were provided
        explicit basic_ofstream(_Filet *_File)
                 ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\fstream:1035:2: note: candidate constructor not viable: requires single argument '_Right', but no arguments were provided
        basic_ofstream(_Myt&& _Right)
        ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\fstream:1065:2: note: candidate constructor not viable: requires 1 argument, but 0 were provided
        basic_ofstream(const _Myt&) = delete;
        ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\fstream:978:11: note: candidate constructor not viable: requires at least argument '_Filename', but no arguments were
      provided
        explicit basic_ofstream(const char *_Filename,
                 ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\fstream:987:11: note: candidate constructor not viable: requires at least argument '_Str', but no arguments were provided
        explicit basic_ofstream(const string& _Str,
                 ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\fstream:994:11: note: candidate constructor not viable: requires at least argument '_Filename', but no arguments were
      provided
        explicit basic_ofstream(const wchar_t *_Filename,
                 ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\fstream:1003:11: note: candidate constructor not viable: requires at least argument '_Str', but no arguments were provided
        explicit basic_ofstream(const wstring& _Str,
                 ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\fstream:1019:11: note: candidate constructor not viable: requires at least argument '_Filename', but no arguments were
      provided
        explicit basic_ofstream(const unsigned short *_Filename,
                 ^
In file included from input_line_19:1:
\\[filepath]\root\R1R2_3.0.1.C:246:14: error: no matching constructor for initialization of 'std::stringstream' (aka 'basic_stringstream<char,
      char_traits<char>, allocator<char> >')
stringstream ss(path);
             ^  ~~~~
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\sstream:589:11: note: candidate constructor not viable: no known conversion from 'std::string' (aka 'basic_string<char,
      char_traits<char>, allocator<char> >') to 'ios_base::openmode' (aka 'int') for 1st argument
        explicit basic_stringstream(ios_base::openmode _Mode =
                 ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\sstream:603:2: note: candidate constructor not viable: no known conversion from 'std::string' (aka 'basic_string<char,
      char_traits<char>, allocator<char> >') to 'std::basic_stringstream<char,
      std::char_traits<char>, std::allocator<char> >::_Myt' (aka 'basic_stringstream<char,
      std::char_traits<char>, std::allocator<char> >') for 1st argument
        basic_stringstream(_Myt&& _Right)
        ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\sstream:633:2: note: candidate constructor not viable: no known conversion from 'std::string' (aka 'basic_string<char,
      char_traits<char>, allocator<char> >') to 'const std::basic_stringstream<char,
      std::char_traits<char>, std::allocator<char> >::_Myt' (aka 'const basic_stringstream<char,
      std::char_traits<char>, std::allocator<char> >') for 1st argument
        basic_stringstream(const _Myt&) = delete;
        ^
In file included from input_line_19:1:
\\[filepath]\root\R1R2_3.0.1.C:250:14: error: no matching constructor for initialization of 'std::stringstream' (aka 'basic_stringstream<char,
      char_traits<char>, allocator<char> >')
stringstream ss_(fname);
             ^   ~~~~~
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\sstream:589:11: note: candidate constructor not viable: no known conversion from 'std::string' (aka 'basic_string<char,
      char_traits<char>, allocator<char> >') to 'ios_base::openmode' (aka 'int') for 1st argument
        explicit basic_stringstream(ios_base::openmode _Mode =
                 ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\sstream:603:2: note: candidate constructor not viable: no known conversion from 'std::string' (aka 'basic_string<char,
      char_traits<char>, allocator<char> >') to 'std::basic_stringstream<char,
      std::char_traits<char>, std::allocator<char> >::_Myt' (aka 'basic_stringstream<char,
      std::char_traits<char>, std::allocator<char> >') for 1st argument
        basic_stringstream(_Myt&& _Right)
        ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\sstream:633:2: note: candidate constructor not viable: no known conversion from 'std::string' (aka 'basic_string<char,
      char_traits<char>, allocator<char> >') to 'const std::basic_stringstream<char,
      std::char_traits<char>, std::allocator<char> >::_Myt' (aka 'const basic_stringstream<char,
      std::char_traits<char>, std::allocator<char> >') for 1st argument
        basic_stringstream(const _Myt&) = delete;
        ^

Start-up error:

RegQueryValueEx: returned 2: The system cannot find the file specified.
RegOpenKeyEx: returned 2: The system cannot find the file specified.
RegQueryValueEx: returned 2: The system cannot find the file specified.
RegOpenKeyEx: returned 2: The system cannot find the file specified.
RegQueryValueEx: returned 2: The system cannot find the file specified.
RegOpenKeyEx: returned 2: The system cannot find the file specified.
RegQueryValueEx: returned 2: The system cannot find the file specified.
RegOpenKeyEx: returned 2: The system cannot find the file specified.
RegQueryValueEx: returned 2: The system cannot find the file specified.
RegOpenKeyEx: returned 2: The system cannot find the file specified.
RegOpenKeyEx: returned 2: The system cannot find the file specified.
RegOpenKeyEx: returned 2: The system cannot find the file specified.
RegOpenKeyEx: returned 2: The system cannot find the file specified.
RegOpenKeyEx: returned 2: The system cannot find the file specified.
In file included from input_line_3:39:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.14.26428\include\cassert:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt\assert.h:12:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt\corecrt.h:131:12: error: redefinition of '_CrtEnableIf<true, _Ty>'
    struct _CrtEnableIf<true, _Ty>
           ^~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\ucrt\corecrt.h:131:12: note: previous definition is here
    struct _CrtEnableIf<true, _Ty>
           ^
In file included from input_line_3:39:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.14.26428\include\cassert:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt\assert.h:12:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt\corecrt.h:488:16: error: redefinition of '__crt_locale_data_public'
typedef struct __crt_locale_data_public
               ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\ucrt\corecrt.h:488:16: note: previous definition is here
typedef struct __crt_locale_data_public
               ^
In file included from input_line_3:39:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.14.26428\include\cassert:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt\assert.h:12:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt\corecrt.h:495:16: error: redefinition of '__crt_locale_pointers'
typedef struct __crt_locale_pointers
               ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\ucrt\corecrt.h:495:16: note: previous definition is here
typedef struct __crt_locale_pointers
               ^
In file included from input_line_3:39:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.14.26428\include\cassert:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt\assert.h:12:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt\corecrt.h:503:16: error: redefinition of '_Mbstatet'
typedef struct _Mbstatet
               ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\ucrt\corecrt.h:503:16: note: previous definition is here
typedef struct _Mbstatet
               ^
   ------------------------------------------------------------
  | Welcome to ROOT 6.14/00                http://root.cern.ch |
  |                               (c) 1995-2018, The ROOT Team |
  | Built for win32                                            |
  | From tag v6-14-00, 13 June 2018                            |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
   ------------------------------------------------------------

root [0]

Thanks in advance,
Alistair


_ROOT Version: 6.14
_Platform: Windows 10 Pro
Compiler: Not Provided


On windows you can use 6.14 only. Try with 6.14/02.

1 Like

Alright, I shall upgrade and let you know how I get on.

Hi, sorry for the delayed reply - I’ve now upgraded and am still running into the same issues with the same file.

do you have the same problem on linux ? (if you can try…)

I have Root 6.10/08 on Linux and the macro runs fine (I wrote it on the Linux system), although with further editing it does now run into the same error when the macro is run twice on Linux without quitting Root in between.

May be you should try to fix that first on Linux ? When you run a macro twice you may get errors if you have some ROOT objects still alive and if you try to recreate them. Any way it seems that on Windows you cannot even run it once. That’s something specific to windows. @bellenot may have an idea about this.

1 Like

Thanks for this; I think the Linux problem is the definition of the event class being redefined on Run 2 which Root obviously doesn’t like, but it definitely remains a mystery as to why it doesn’t run at all on Windows!

Hi,

Please make sure you updated your version of Visual Studio, and then start again, and send the exact command you type, and the error messages you have (half of them must have been gone when updating from 6.14.00 to 6.14.02…)

Cheers, Bertrand.

1 Like

I think this might be where part of my issue is arising from; I’m not sure Root is correctly set up with Visual Studio; I performed a clean install of both for the first time at the weekend, but I’m not sure if there was an extra step I’ve missed after that, or does Root automatically look for Visual Studio to be installed?

For now, you should install the latest version of Visual Studio, with all the updates, and the latest Windows 10 SDK (we’ll try to get rid of this limitation). And don’t forget that ROOT on Windows is still an alpha release!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.