View Issue Details

IDProjectCategoryView StatusLast Update
0027478CommunityOCCT:Configurationpublic2016-12-09 16:37
ReporterBenjaminBihler Assigned Tokgv  
PrioritynormalSeverityintegration request 
Status closedResolutionfixed 
PlatformLinuxOSDebian 64 Bit 
Product Version7.0.0 
Target Version7.1.0Fixed in Version7.1.0 
Summary0027478: Configuration - avoid inclusion of Xlib.h within Graphic3d_GraphicDriver.hxx
DescriptionXlib.h is a terrible include file. It defines keywords like None, Unsorted, Status, Bool and so on (see InterfaceGraphic.hxx below the line starting with "// workaround name conflicts").

If a header file includes Xlib.h, including that header file becomes dangerous, since whenever keywords like the ones named above are used, the compiler will report errors. Sometimes this is necessary (for example if an element defined in Xlib.h is a member field of a class), but it should be done as rarely as possible.

This compile problem happens here. One of my header files must include Graphic3d_GraphicDriver.hxx, which includes Aspect_DisplayConnection.hxx, which includes InterfaceGraphic.hxx, which includes Xlib.h. And this polluted chain makes g++ refuse compiling my project (this has not been the case with OCCT 6.8.0). :-(

One possibility to solve that would be to stop Graphic3d_GraphicDriver.hxx from including Aspect_DisplayConnection.hxx. Since Graphic3d_GraphicDriver has a member field of type Handle(Aspect_DisplayConnection), it needs to know that handle.

I will create a proposal commit by removing the include and adding the handle definition to Graphic3d_GraphicDriver.hxx.

Caution: This actually means duplication of the handle definition code. This in turn could be prevented by creating a file Aspect_DisplayConnection_Handle.hxx which could contain the handle definition and had to be included by everyone interested in that handle. Do you prefer that? Or do you have another standard way to deal with such cases?

Thank you!
Steps To ReproduceNot required
TagsNo tags attached.
Test case number

Activities

git

2016-05-09 17:33

administrator   ~0053920

Branch CR27478 has been created by BenjaminBihler.

SHA-1: 27c333c7d64165bed4dc156f271fd1890b0d22e9


Detailed log of new commits:

Author: Benjamin Bihler
Date: Mon May 9 16:31:38 2016 +0200

    0027478: The Include Chain is Polluted with Xlib.h
    
    Removed inclusion of Aspect_DisplayConnection.hxx fromGraphic3d_GraphicDriver.hxx
    and added handle definition.

kgv

2016-05-09 18:07

developer   ~0053921

> Caution: This actually means duplication of the handle definition code.
> This in turn could be prevented by creating a file Aspect_DisplayConnection_Handle.hxx which could contain the handle definition and had to be included by everyone interested in that handle.

Since OCCT 7.0.0 handle is a template class - so there would not be a duplicate class definition (typedef to the same type is perfectly fine). Technically forward-declared Aspect_DisplayConnection should be sufficient in this context - no need to use DEFINE_STANDARD_HANDLE macros.

However, in particular cases compiler may complain about missing class definition when instantiating destructor of handle template - which can be solved by adding empty exported destructor ~Graphic3d_GraphicDriver() (otherwise implicit default destructor might be instantiated at application code causing this error).

git

2016-05-10 12:51

administrator   ~0053944

Branch CR27478 has been updated by BenjaminBihler.

SHA-1: 1ce974d32838656fa00f91f18abbe0942beed711


Detailed log of new commits:

Author: Benjamin Bihler
Date: Tue May 10 11:50:36 2016 +0200

    0027478: Configuration - avoid inclusion of Xlib.h within Graphic3d_GraphicDriver.hxx
    
    Replaced handle definition by forward declaration.

BenjaminBihler

2016-05-10 12:52

developer   ~0053945

You are right (I still have to get used to the new handle). I have removed the DEFINE_STANDARD_HANDLE macro and added the forward declaration. It works here on Windows 64 and on Linux. The empty exported destructor I have not added, since it has not been necessary here.

git

2016-05-10 21:00

administrator   ~0053973

Branch CR27478_1 has been created by kgv.

SHA-1: 5950d7816e4dd6f51d1deaea767d65f80b607bc3


Detailed log of new commits:

Author: Benjamin Bihler
Date: Tue May 10 20:59:55 2016 +0300

    0027478: Configuration - avoid inclusion of Xlib.h within Graphic3d_GraphicDriver.hxx
    
    Replace Aspect_DisplayConnection.hxx inclusion by forward declaration.

kgv

2016-05-10 21:01

developer   ~0053974

Please check compilation of the patch in branch CR27478_1.
Regression testing is not needed.

git

2016-05-20 12:21

administrator   ~0054180

Branch CR27478_1 has been deleted by inv.

SHA-1: 5950d7816e4dd6f51d1deaea767d65f80b607bc3

git

2016-05-20 12:21

administrator   ~0054182

Branch CR27478 has been deleted by inv.

SHA-1: 1ce974d32838656fa00f91f18abbe0942beed711

Related Changesets

occt: master 5950d781

2016-05-10 17:59:55

BenjaminBihler


Committer: kgv Details Diff
0027478: Configuration - avoid inclusion of Xlib.h within Graphic3d_GraphicDriver.hxx

Replace Aspect_DisplayConnection.hxx inclusion by forward declaration.
Affected Issues
0027478
mod - src/Graphic3d/Graphic3d_GraphicDriver.hxx Diff File

Issue History

Date Modified Username Field Change
2016-05-09 17:28 BenjaminBihler New Issue
2016-05-09 17:28 BenjaminBihler Assigned To => BenjaminBihler
2016-05-09 17:33 git Note Added: 0053920
2016-05-09 17:37 BenjaminBihler Assigned To BenjaminBihler => kgv
2016-05-09 17:37 BenjaminBihler Status new => resolved
2016-05-09 17:37 BenjaminBihler Steps to Reproduce Updated
2016-05-09 17:59 kgv Severity minor => integration request
2016-05-09 17:59 kgv Category OCCT:Visualization => OCCT:Configuration
2016-05-09 18:07 kgv Note Added: 0053921
2016-05-09 18:08 kgv Summary The Include Chain is Polluted with Xlib.h => Configuration - avoid includsion of Xlib.h within Graphic3d_GraphicDriver.hxx
2016-05-09 18:08 kgv Summary Configuration - avoid includsion of Xlib.h within Graphic3d_GraphicDriver.hxx => Configuration - avoid inclusion of Xlib.h within Graphic3d_GraphicDriver.hxx
2016-05-10 12:51 git Note Added: 0053944
2016-05-10 12:52 BenjaminBihler Note Added: 0053945
2016-05-10 21:00 git Note Added: 0053973
2016-05-10 21:01 kgv Note Added: 0053974
2016-05-10 21:01 kgv Assigned To kgv => bugmaster
2016-05-10 21:01 kgv Status resolved => reviewed
2016-05-13 12:41 kgv Changeset attached => occt master 5950d781
2016-05-13 12:41 kgv Assigned To bugmaster => kgv
2016-05-13 12:41 kgv Status reviewed => verified
2016-05-13 12:41 kgv Resolution open => fixed
2016-05-20 12:21 git Note Added: 0054180
2016-05-20 12:21 git Note Added: 0054182
2016-12-09 16:33 aiv Status verified => closed
2016-12-09 16:37 aiv Fixed in Version => 7.1.0