Re: [ROOT] Root Conflicts with Windows

From: Valeri Fine (Faine) (fine@bnl.gov)
Date: Wed Sep 27 2000 - 20:34:42 MEST


Hello,  Dimitris

 I've looked up your code more carefully.

 I am afraid you may not solve the problem the way you want.
 I think what you should separate the source like someone has advised on roottalk,

Try don't  mix ROOT and Windows include files within one source code.

For example just put your int ReadAscii() function into the separate source file
and you will  have no need for "TFile include" for your "eva.cpp". The same things for
other functions. This way code will be cleaner and more easy to maintain too.

And of course your task would be much simpler to achieve if you choose the recommended
way, Namely create the DLL with your function and load it in to the regular
ROOT session. I see no advantage of your "stand-alone" code but headaches only.

The main problem you will meet on your way is  lacking of the "Console Window". Many
ROOT classes assume  the "Console window" for granted to display the various warning
and error messages. Since you created so-called "Win32 application" no "console will be
provided and you will see no message from ROOT. Very likely your application will crash
shortly.

ROOT was designed with the cross platform compatible codes in mind. This is to say
one should not mix the platform depended (like the low level windows management) and
application ROOT-based functions within one and the same piece of code.
I think it is naturally to separate such kind of things. Try to do that and you will
have no problem to fight with.

I think you should create very simple ROOT DLL with the class with ReadAscii
method ONLY. May be you should post your example to roottalk and make it available
on net.

I believe you will get a lot of useful comments on your design and this save your time.
Very likely you will need to spend some time learning  ROOT but it will pay off.

 I am sorry I can not help much at the moment due my vacation.

                            With my best regards , Valery
----- Original Message -----
From: Dr. D. Sideris <d.sideris@ic.ac.uk>
To: Valeri Fine (Faine) <fine@bnl.gov>
Sent: 27 сентября 2000 г. 13:39
Subject: Re: [ROOT] Root Conflicts with Windows


> Hi Valeri,
>
> I've tried what you said as you can see in the fragment below, and the
> errors were indeed reduced considerably but I still got a conflict. I paste
> the compilation result aswell. Thanks for the effort
>
> Dimitris
>
> --------------------Configuration: eva - Win32 Debug--------------------
> Compiling...
> a.cpp
> d:\root\eva\a.cpp(16) : warning C4244: 'return' : conversion from 'int' to
> 'float', possible loss of data
> d:\root\eva\a.cpp(20) : warning C4244: 'return' : conversion from 'double'
> to 'float', possible loss of data
> eva.cpp
> d:\root\eva\eva.cpp(148) : error C2065: 'CreateWindow' : undeclared
> identifier
> d:\root\eva\eva.cpp(149) : error C2440: '=' : cannot convert from 'int' to
> 'struct HWND__ *'
>         Conversion from integral type to pointer type requires
> reinterpret_cast, C-style cast or function-style cast
> d:\root\eva\eva.cpp(207) : error C2065: 'DrawText' : undeclared identifier
> d:\root\eva\eva.cpp(262) : warning C4305: 'initializing' : truncation from
> 'const double' to 'float'
> d:\root\eva\eva.cpp(266) : warning C4305: 'initializing' : truncation from
> 'const double' to 'float'
> Generating Code...
> Error executing cl.exe.
>
> eva.exe - 3 error(s), 4 warning(s)
>
> ////////////////////////////////////////////////////////////////////////////
> /////////////////////////////////////////////////////////
> // eva.cpp : Defines the entry point for the application.
> //
> #include "stdafx.h"
> #include "resource.h"
> #include "Windows4Root.h"
> #include "A.h"
> #include "TROOT.h"
> extern void InitGui();
> VoidFuncPtr_t initfuncs[] = { InitGui, 0 };
> TROOT root("rint", "The ROOT Interactive Interface", initfuncs);
>
>
>
>
> #define MAX_LOADSTRING 100
>
>
> // ROOT Headers etc
>
> int ReadAscii(void);
>
>
> #include "TFile.h"
> #include "TTree.h"
> #include "TRandom.h"
>
> #include "TApplication.h"
> #include "TCanvas.h"
> #include "TLine.h"
> #include "TPaveLabel.h"
>
>
> #include "TH1.h"
> #include "TH2.h"
> #include "TF1.h"
> #include "TProfile.h"
> #include "TAxis.h"
> #include "TPad.h"
>
> ----- Original Message -----
> From: Valeri Fine (Faine) <fine@bnl.gov>
> To: Dr. D. Sideris <d.sideris@ic.ac.uk>
> Sent: Tuesday, September 26, 2000 8:22 PM
> Subject: Re: [ROOT] Root Conflicts with Windows
>
>
> >
> > Windows
> >
> >
> > > Did it and there is no change at all. I paste the output of the
> compilation.
> > >
> > > Regards
> > >
> >
> > I found another place in your code:
> > It has the same kind of problem the "VC++ " include follows
> > the "ROOT" include. You should try to avoid that or add
> > the include "windos4root.h" after the last VC++" include and
> > before the rest "ROOT" headers.
> >
> > I can not compile your code myself at the moment to find a proper
> combination
> > You should get the idea. VC++ contains macro "CreateWindows"
> > This macro is expanded to CreateWindowsA, then the compiler applies this
> > expansion to the TVirtualX::CreateWindows method name and this srew
> everything
> > because now that class got a new method
> >
> >    TVirtualX::CreateWindowsA
> >
> > etc.
> >
> > This is because ROOT team did not want to correct "ROOT"  name in favor of
> > one's Microsoft. They said Microsoft should change not we ;-(.
> >
> >                             Valery
> >
> >
> >
> > #include "TROOT.h"
> > extern void InitGui();
> > VoidFuncPtr_t initfuncs[] = { InitGui, 0 };
> > TROOT root("rint", "The ROOT Interactive Interface", initfuncs);
> >
> >
> > #include "resource.h"
> >
> > #define MAX_LOADSTRING 100
> >
> >
> > // ROOT Headers etc
> >
> > int ReadAscii(void);
> >
> > #include "A.h"
> >
> >
> > > Dimitris
> > >
> > >
> > > --------------------Configuration: eva - Win32 Debug--------------------
> > > Compiling resources...
> > > Compiling...
> > > StdAfx.cpp
> > > Compiling...
> > > a.cpp
> > > d:\root\eva\a.cpp(15) : warning C4244: 'return' : conversion from 'int'
> to
> > > 'float', possible loss of data
> > > d:\root\eva\a.cpp(19) : warning C4244: 'return' : conversion from
> 'double'
> > > to 'float', possible loss of data
> > > a_cint.cpp
> > > eva.cpp
> > > d:\root\include\tvirtualx.h(164) : warning C4003: not enough actual
> > > parameters for macro 'CreateWindowA'
> > > d:\root\include\tvirtualx.h(164) : error C2059: syntax error :
> 'constant'
> > > d:\root\include\tvirtualx.h(343) : warning C4003: not enough actual
> > > parameters for macro 'CreateWindowA'
> > > d:\root\include\tvirtualx.h(343) : error C2275: 'Window_t' : illegal use
> of
> > > this type as an expression
> > >         d:\root\include\guitypes.h(30) : see declaration of 'Window_t'
> > > d:\root\include\tvirtualx.h(343) : error C2275: 'Int_t' : illegal use of
> > > this type as an expression
> > >         d:\root\include\rtypes.h(42) : see declaration of 'Int_t'
> > > d:\root\include\tvirtualx.h(343) : error C2275: 'Int_t' : illegal use of
> > > this type as an expression
> > >         d:\root\include\rtypes.h(42) : see declaration of 'Int_t'
> > > d:\root\include\tvirtualx.h(343) : error C2275: 'UInt_t' : illegal use
> of
> > > this type as an expression
> > >         d:\root\include\rtypes.h(43) : see declaration of 'UInt_t'
> > > d:\root\include\tvirtualx.h(343) : error C2275: 'UInt_t' : illegal use
> of
> > > this type as an expression
> > >         d:\root\include\rtypes.h(43) : see declaration of 'UInt_t'
> > > d:\root\include\tvirtualx.h(343) : error C2275: 'UInt_t' : illegal use
> of
> > > this type as an expression
> > >         d:\root\include\rtypes.h(43) : see declaration of 'UInt_t'
> > > d:\root\include\tvirtualx.h(343) : error C2275: 'Int_t' : illegal use of
> > > this type as an expression
> > >         d:\root\include\rtypes.h(42) : see declaration of 'Int_t'
> > > d:\root\include\tvirtualx.h(343) : error C2275: 'UInt_t' : illegal use
> of
> > > this type as an expression
> > >         d:\root\include\rtypes.h(43) : see declaration of 'UInt_t'
> > > d:\root\include\tvirtualx.h(343) : error C2062: type 'void' unexpected
> > > d:\root\include\tvirtualx.h(343) : error C2143: syntax error : missing
> ';'
> > > before '{'
> > > d:\root\include\tvirtualx.h(343) : error C2447: missing function header
> > > (old-style formal list?)
> > > d:\root\eva\eva.cpp(258) : warning C4305: 'initializing' : truncation
> from
> > > 'const double' to 'float'
> > > d:\root\eva\eva.cpp(262) : warning C4305: 'initializing' : truncation
> from
> > > 'const double' to 'float'
> > > Generating Code...
> > > Error executing cl.exe.
> > >
> > > eva.exe - 12 error(s), 6 warning(s)
> > > ----- Original Message -----
> > > From: Valeri Fine (Faine) <fine@bnl.gov>
> > > To: Dr. D. Sideris <d.sideris@ic.ac.uk>
> > > Cc: <roottalk@cern.ch>
> > > Sent: Tuesday, September 26, 2000 7:18 PM
> > > Subject: Re: [ROOT] Root Conflicts with Windows
> > >
> > >
> > > Hello, Dimitris
> > >   Can you try to exchange two header files from "a.h"
> > >
> > > #include "TObject.h"
> > > #include "stdafx.h"
> > >
> > > with
> > >
> > > #include "stdafx.h"
> > > #include "TObject.h"
> > >
> > >
> > >  I mean,  introduce the Microsoft header files first then those from
> ROOT.
> > >
> > >  I wonder this may help.
> > >                                             Valery
> > >
> > > ----- Original Message -----
> > > From: Dr. D. Sideris <d.sideris@ic.ac.uk>
> > > To: Valeri Fine (Faine) <fine@bnl.gov>
> > > Sent: 26 qemrap 2000 c. 12:55
> > > Subject: Re: [ROOT] Root Conflicts with Windows
> > >
> > >
> > > > Hi Valerie,
> > > >
> > > >  Here is the output of the compilation, which I think is indicative on
> its
> > > > own.
> > > > I have also attached, the whole eva directory. Note that the code does
> not
> > > > necessarily work properly as it is, since I cannot debug it properly
> due
> > > to
> > > > the conflicts below. But if you compile it you would get (hopefully)
> the
> > > > errors below.
> > > >
> > > > Dimitris
> > > >
> > > >
> > > >
> > > > --------------------Configuration: eva - Win32
> Debug--------------------
> > > > Compiling...
> > > > eva.cpp
> > > > d:\root\include\tvirtualx.h(164) : warning C4003: not enough actual
> > > > parameters for macro 'CreateWindowA'
> > > > d:\root\include\tvirtualx.h(164) : error C2059: syntax error :
> 'constant'
> > > > d:\root\include\tvirtualx.h(343) : warning C4003: not enough actual
> > > > parameters for macro 'CreateWindowA'
> > > > d:\root\include\tvirtualx.h(343) : error C2275: 'Window_t' : illegal
> use
> > > of
> > > > this type as an expression
> > > >         d:\root\include\guitypes.h(30) : see declaration of 'Window_t'
> > > > d:\root\include\tvirtualx.h(343) : error C2275: 'Int_t' : illegal use
> of
> > > > this type as an expression
> > > >         d:\root\include\rtypes.h(42) : see declaration of 'Int_t'
> > > > d:\root\include\tvirtualx.h(343) : error C2275: 'Int_t' : illegal use
> of
> > > > this type as an expression
> > > >         d:\root\include\rtypes.h(42) : see declaration of 'Int_t'
> > > > d:\root\include\tvirtualx.h(343) : error C2275: 'UInt_t' : illegal use
> of
> > > > this type as an expression
> > > >         d:\root\include\rtypes.h(43) : see declaration of 'UInt_t'
> > > > d:\root\include\tvirtualx.h(343) : error C2275: 'UInt_t' : illegal use
> of
> > > > this type as an expression
> > > >         d:\root\include\rtypes.h(43) : see declaration of 'UInt_t'
> > > > d:\root\include\tvirtualx.h(343) : error C2275: 'UInt_t' : illegal use
> of
> > > > this type as an expression
> > > >         d:\root\include\rtypes.h(43) : see declaration of 'UInt_t'
> > > > d:\root\include\tvirtualx.h(343) : error C2275: 'Int_t' : illegal use
> of
> > > > this type as an expression
> > > >         d:\root\include\rtypes.h(42) : see declaration of 'Int_t'
> > > > d:\root\include\tvirtualx.h(343) : error C2275: 'UInt_t' : illegal use
> of
> > > > this type as an expression
> > > >         d:\root\include\rtypes.h(43) : see declaration of 'UInt_t'
> > > > d:\root\include\tvirtualx.h(343) : error C2062: type 'void' unexpected
> > > > d:\root\include\tvirtualx.h(343) : error C2143: syntax error : missing
> ';'
> > > > before '{'
> > > > d:\root\include\tvirtualx.h(343) : error C2447: missing function
> header
> > > > (old-style formal list?)
> > > > d:\root\eva\eva.cpp(258) : warning C4305: 'initializing' : truncation
> from
> > > > 'const double' to 'float'
> > > > d:\root\eva\eva.cpp(262) : warning C4305: 'initializing' : truncation
> from
> > > > 'const double' to 'float'
> > > > Error executing cl.exe.
> > > >
> > > > eva.exe - 12 error(s), 4 warning(s)
> > > >
> > > > ----- Original Message -----
> > > > From: Valeri Fine (Faine) <fine@bnl.gov>
> > > > To: Dr. D. Sideris <d.sideris@ic.ac.uk>
> > > > Cc: <roottalk@pcroot.cern.ch>
> > > > Sent: Tuesday, September 26, 2000 4:19 PM
> > > > Subject: Re: [ROOT] Root Conflicts with Windows
> > > >
> > > >
> > > > Dear Dimitris Sideris
> > > >
> > > > Would you mind and to provide any example to understand where
> > > > your trouble came from.
> > > >
> > > >   The generic recommended way creating ROOT-base application is to
> make
> > > > the custom DLL with the  user custom class and Root/Cint dictionary
> and
> > > load
> > > > that DLL into the regular ROOT session via gSystem->Load(<name of your
> > > > DLL>).
> > > >
> > > > %ROOTSYS%\test subdirectory should contain the examples of the custom
> > > > classes
> > > > and ROOT macros and Makefile (for Microsoft NMAKE utility).
> > > >
> > > >
> > > >               Valery
> > > >
> > > > ----- Original Message -----
> > > > From: Dr. D. Sideris <d.sideris@ic.ac.uk>
> > > > To: <roottalk@pcroot.cern.ch>
> > > > Sent: 26 qemrap 2000 c. 7:34
> > > > Subject: [ROOT] Root Conflicts with Windows
> > > >
> > > >
> > > > Dear Root team, I'm trying to incorporate root in my c++ windows NT
> AFC
> > > > application. There seem to be major conflicts between
> > > > the libraries of root and windows. The suggested solution on the root
> > > > documentation is to wrap root inside a class. But this
> > > > implies effective manual renaming of every single call to root
> functions.
> > > >
> > > > Regards
> > > >
> > > > Dimitris Sideris
> > > > Imperial College London
> > > >
> > > >
> > > >
> > >
> > >
> > >
> >
>
>



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:34 MET