Problem converting program to MS VC++ 2008 Express

Dear Rooters

I am just trying to convert my program from MacOS X and Linux to VC++ and get many unexpected compilation errors.
Some errors are annoying but easy to solve, for others I would appreciate any help.

  1. Here is the first problem where I need help. I have the following code fragment:
   char  strg[128];
   tree->Branch("strg", strg, "strg[128]/C");

and get the following error:

XPSData.cxx(3440) : error C2666: 'TTree::Branch' : 2 overloads have similar conversions
        c:\root\include\TTree.h(207): could be 'TBranch *TTree::Branch(const char *,const char *,void *,Int_t,Int_t)'
        c:\root\include\TTree.h(205): or       'TBranch *TTree::Branch(const char *,void *,const char *,Int_t)'
        while trying to match the argument list '(const char [5], char [128], const char [12])'

How can I solve this problem?

  1. At many places I have the following code fragments to avoid warnings from gcc:
   virtual Double_t GetValue(const char */*name*/)  {return 0;}

Sadly, this results in the following warning with VC++:

c:\home\rabbitus\rootcode\xps\XPSBase.h(210) : warning C4138: '*/' found outside of comment

Is there a solution which avoids warnings in both gcc and VC++?

  1. Here are some code fragments resulting in compilation errors, which I could solve:
   char *pos = strchr(name,sep);
// must be changed to:
   char *pos = strchr((char*)name,sep);

   char *s = (char*)(name.Data());
   *s = std::toupper(s[0]);
// must be changed to:
   *s = toupper(s[0]);

Does MS VC++ not follow the C++ standard or is this my mistake?

Thank you in advance.
Best regards
Christian

[quote]

  1. Here is the first problem where I need help. I have the following code fragment: [/quote]Use char strg[128]; tree->Branch("strg", (void*)strg, "strg[128]/C");

[quote]2. At many places I have the following code fragments to avoid warnings from gcc:[/quote]Use:virtual Double_t GetValue(const char * /*name*/) {return 0;}(note the extra spaces)

Cheers,
Philippe

Hi Christian.

Well, actually MSVC++ does follow the standard:

char *strchr(const char *str, int c); // C only char *strchr( char *str, int c); // C++ only const char *strchr(const char *str, int c); // C++ only(note the different signatures…)

Cheers,
Bertrand.

Dear Philippe, dear Bertrand

Thank you for your help and comments, now I can compile everything with VC++.

However, there remains one (hopefully) last problem as the following output of my compilation shows:

C:\home\Rabbitus\rootcode\xps>NMAKE /f "Makefile.win32" CFG="Debug"

Microsoft (R) Program Maintenance Utility Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.

        cl  -D_MT -D_DLL -MDd -EHsc -nologo -GR -DWIN32  -DVISUAL_CPLUSPLUS -D_W
INDOWS -Ic:\root/include -D_CRT_SECURE_NO_DEPRECATE -Z7 -MDd -c TMLMath.cxx
TMLMath.cxx
TMLMath.cxx(1109) : warning C4005: 'xmax' : macro redefinition
        TMLMath.cxx(1060) : see previous definition of 'xmax'
        cl  -D_MT -D_DLL -MDd -EHsc -nologo -GR -DWIN32  -DVISUAL_CPLUSPLUS -D_W
INDOWS -Ic:\root/include -D_CRT_SECURE_NO_DEPRECATE -Z7 -MDd -c TStat.cxx
TStat.cxx
        cl  -D_MT -D_DLL -MDd -EHsc -nologo -GR -DWIN32  -DVISUAL_CPLUSPLUS -D_W
INDOWS -Ic:\root/include -D_CRT_SECURE_NO_DEPRECATE -Z7 -MDd -c StatUtils.cxx
StatUtils.cxx
        cl  -D_MT -D_DLL -MDd -EHsc -nologo -GR -DWIN32  -DVISUAL_CPLUSPLUS -D_W
INDOWS -Ic:\root/include -D_CRT_SECURE_NO_DEPRECATE -Z7 -MDd -c XPSBase.cxx
XPSBase.cxx
        cl  -D_MT -D_DLL -MDd -EHsc -nologo -GR -DWIN32  -DVISUAL_CPLUSPLUS -D_W
INDOWS -Ic:\root/include -D_CRT_SECURE_NO_DEPRECATE -Z7 -MDd -c XPSUtils.cxx
XPSUtils.cxx
        cl  -D_MT -D_DLL -MDd -EHsc -nologo -GR -DWIN32  -DVISUAL_CPLUSPLUS -D_W
INDOWS -Ic:\root/include -D_CRT_SECURE_NO_DEPRECATE -Z7 -MDd -c XPSSchemes.cxx
XPSSchemes.cxx
        cl  -D_MT -D_DLL -MDd -EHsc -nologo -GR -DWIN32  -DVISUAL_CPLUSPLUS -D_W
INDOWS -Ic:\root/include -D_CRT_SECURE_NO_DEPRECATE -Z7 -MDd -c XPSDataTypes.cxx

XPSDataTypes.cxx
        cl  -D_MT -D_DLL -MDd -EHsc -nologo -GR -DWIN32  -DVISUAL_CPLUSPLUS -D_W
INDOWS -Ic:\root/include -D_CRT_SECURE_NO_DEPRECATE -Z7 -MDd -c XPSProjectHandle
r.cxx
XPSProjectHandler.cxx
        cl  -D_MT -D_DLL -MDd -EHsc -nologo -GR -DWIN32  -DVISUAL_CPLUSPLUS -D_W
INDOWS -Ic:\root/include -D_CRT_SECURE_NO_DEPRECATE -Z7 -MDd -c XPSData.cxx
XPSData.cxx
        cl  -D_MT -D_DLL -MDd -EHsc -nologo -GR -DWIN32  -DVISUAL_CPLUSPLUS -D_W
INDOWS -Ic:\root/include -D_CRT_SECURE_NO_DEPRECATE -Z7 -MDd -c XPSProcessing.cx
x
XPSProcessing.cxx
        cl  -D_MT -D_DLL -MDd -EHsc -nologo -GR -DWIN32  -DVISUAL_CPLUSPLUS -D_W
INDOWS -Ic:\root/include -D_CRT_SECURE_NO_DEPRECATE -Z7 -MDd -c XPSHybridizer.cx
x
XPSHybridizer.cxx
        cl  -D_MT -D_DLL -MDd -EHsc -nologo -GR -DWIN32  -DVISUAL_CPLUSPLUS -D_W
INDOWS -Ic:\root/include -D_CRT_SECURE_NO_DEPRECATE -Z7 -MDd -c XPSSelector.cxx
XPSSelector.cxx
        cl  -D_MT -D_DLL -MDd -EHsc -nologo -GR -DWIN32  -DVISUAL_CPLUSPLUS -D_W
INDOWS -Ic:\root/include -D_CRT_SECURE_NO_DEPRECATE -Z7 -MDd -c XPSNormalizer.cx
x
XPSNormalizer.cxx
        cl  -D_MT -D_DLL -MDd -EHsc -nologo -GR -DWIN32  -DVISUAL_CPLUSPLUS -D_W
INDOWS -Ic:\root/include -D_CRT_SECURE_NO_DEPRECATE -Z7 -MDd -c XPSPreProcessing
.cxx
XPSPreProcessing.cxx
        cl  -D_MT -D_DLL -MDd -EHsc -nologo -GR -DWIN32  -DVISUAL_CPLUSPLUS -D_W
INDOWS -Ic:\root/include -D_CRT_SECURE_NO_DEPRECATE -Z7 -MDd -c XPSNormation.cxx

XPSNormation.cxx
        cl  -D_MT -D_DLL -MDd -EHsc -nologo -GR -DWIN32  -DVISUAL_CPLUSPLUS -D_W
INDOWS -Ic:\root/include -D_CRT_SECURE_NO_DEPRECATE -Z7 -MDd -c XPSFilter.cxx
XPSFilter.cxx
        cl  -D_MT -D_DLL -MDd -EHsc -nologo -GR -DWIN32  -DVISUAL_CPLUSPLUS -D_W
INDOWS -Ic:\root/include -D_CRT_SECURE_NO_DEPRECATE -Z7 -MDd -c XPSAnalyzer.cxx
XPSAnalyzer.cxx
        cl  -D_MT -D_DLL -MDd -EHsc -nologo -GR -DWIN32  -DVISUAL_CPLUSPLUS -D_W
INDOWS -Ic:\root/include -D_CRT_SECURE_NO_DEPRECATE -Z7 -MDd -c XPSAnalysis.cxx
XPSAnalysis.cxx
        cl  -D_MT -D_DLL -MDd -EHsc -nologo -GR -DWIN32  -DVISUAL_CPLUSPLUS -D_W
INDOWS -Ic:\root/include -D_CRT_SECURE_NO_DEPRECATE -Z7 -MDd -c rwrapper.cxx
rwrapper.cxx
"Generating dictionary xpsDict.cxx..."
Error: C:\root\bin\rootcint.EXE: xpsLinkDef.h must be last file on command line
NMAKE : fatal error U1077: 'C:\root\bin\rootcint.EXE' : return code '0x1'
Stop.

VC++ is not able to create the dictionary, and I do not understand the error message.
Do you know what the reason might be?

For your information I am attaching the makefile.

Best regards
Christian
Makefile.win32.txt (4.92 KB)

Hi Christian,

Try replace white spaces by TABs as shown there:

### $(MAIN).$(ObjSuf): $(MYHDR) $(MAIN)Dict.$(SrcSuf): $(MYHDR) $(MAIN)LinkDef.h <TAB><TAB>@echo "Generating dictionary $@..." <TAB><TAB>@rootcint -f $@ -c $(MYHDR) $(MAIN)LinkDef.h
(obviously tab characters, and not ‘’)
And move it before the ‘clean:’ target

Please let me know…

Cheers,
Bertrand.

Dear Bertrand

Sadly, this does result in the same error.
Only an empty xpsDict.cxx file is created but no xpsDict.h file.

Best regards
Christian

Sorry, I overlooked your makefile…
Remove “$(MAIN)LinkDef.h” from “MYHDR” list

Bertrand.

Dear Bertrand

Great! Thank you, now it works.

Best regards
Christian

No problem, happy to help :smiley:
Best, Bertrand.

Dear ROOTers

Now, that I could create my library xps.dll I experience the next unexpected problem, I cannot load it!

Here is my situation:
I have a macro containing following function to load my library:

void Init(const char *libxps)
{
   gSystem->Load("libGui");
   gSystem->Load(libxps);
}

The library is located at: "C:\home\Rabbitus\rootcode\xps\xps.dll"
My macro is located at: “E:\ROOT\MS”

Thus, on the MS-DOS console I did: cd /D E:\ROOT\MS
Then I started root and tried to load my library in two different ways:

root [0] .L macro4XPSfat32vc.C
root [1] Init("C:\home\Rabbitus\rootcode\xps\xps.dll")
ootcode does not exist in .;c:\root/bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOW
S\System32\Wbem;c:\Programme\Microsoft SQL Server\90\Tools\binn\;C:\root\bin;C:\
Programme\Microsoft Visual Studio 9.0\VC\bin;C:\Programme\Microsoft SDKs\Windows
\v6.0A\bin;C:\Programme\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90
.CRT;;;c:\root/lib,
or has wrong file extension (.dll)

root [2] Init("/home/Rabbitus/rootcode/xps/xps.dll")
Error in <TWinNTSystem::DynamicPathName>: /home/Rabbitus/rootcode/xps/xps.dll do
es not exist in .;c:\root/bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32
\Wbem;c:\Programme\Microsoft SQL Server\90\Tools\binn\;C:\root\bin;C:\Programme\
Microsoft Visual Studio 9.0\VC\bin;C:\Programme\Microsoft SDKs\Windows\v6.0A\bin
;C:\Programme\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT;;;c:\
root/lib,
or has wrong file extension (.dll)
  1. Can someone tell me how to load a library into root?
  2. Is there a documentation how to use root from WinXP?

Thank you in advance.
Best regards
Christian

Hi,

I think you meant:Init("C:\\home\\Rabbitus\\rootcode\\xps\\xps.dll");

Cheers,
Philippe

[quote=“pcanal”]Hi,

I think you meant:Init("C:\\home\\Rabbitus\\rootcode\\xps\\xps.dll");

Cheers,
Philippe[/quote]There should be no difference
The “right” slashes is the correct way to define the path for Win32 API

Init("/home/Rabbitus/rootcode/xps/xps.dll") The line above should be Ok too

Hi Valery,

[quote=“fine”]Init("/home/Rabbitus/rootcode/xps/xps.dll") The line above should be Ok too[/quote]Not on drive E:.

Axel.

[quote=“Axel”]Not on drive E:.[/quote] E: :open_mouth: I missed we are speaking about drive E:. Of course, if no information about the drive is provided, Windows selects the current drive . If the current drive is E then very this drive is to be used. Did you imply ROOT changes this rule?

Hi Valery,
no I did not.
Axel.