Clang compile error - enumeration previously ... |
Post Reply |
Author | |
jkmgs
Newbie Joined: 25 September 2023 Status: Offline Points: 5 |
Post Options
Thanks(0)
Posted: 25 September 2023 at 5:03am |
Hi there, To be able to apply clang-tidy to our project, I need the Toolkit to compile with Clang. Hereby, I ran into the following four errors, which are all of the same type. Would be great if this could be fixed with the next update: 1. C:\Program Files (x86)\Codejock Software\MFC\Xtreme ToolkitPro v22.1.0\Source\Common\XTPXMLHelpers.h(207): error: enumeration previously declared with fixed underlying type 207 | enum tagDOMNodeType | ^ C:\Program Files (x86)\Codejock Software\MFC\Xtreme ToolkitPro v22.1.0\Source\Common\XTPXMLHelpers.h(80): message: previous declaration is here 80 | XTP_FORWARD_ENUM(tagDOMNodeType); | ^ 2. C:\Program Files (x86)\Codejock Software\MFC\Xtreme ToolkitPro v22.1.0\Source\Common\XTPXMLHelpers.h(740): error: enumeration previously declared with fixed underlying type 740 | enum tagXMLEMEM_TYPE | ^ C:\Program Files (x86)\Codejock Software\MFC\Xtreme ToolkitPro v22.1.0\Source\Common\XTPXMLHelpers.h(144): message: previous declaration is here 144 | XTP_FORWARD_ENUM(tagXMLEMEM_TYPE); | 3. C:\Program Files (x86)\Codejock Software\MFC\Xtreme ToolkitPro v22.1.0\Source\GridControl\XTPGridADO.h(1369): error: enumeration previously declared with fixed underlying type 1369 | enum PositionEnum | ^ C:\Program Files (x86)\Codejock Software\MFC\Xtreme ToolkitPro v22.1.0\Source\GridControl\XTPGridADO.h(1071): message: previous declaration is here 1071 | XTP_FORWARD_ENUM(PositionEnum); | ^ 4. C:\Program Files (x86)\Codejock Software\MFC\Xtreme ToolkitPro v22.1.0\Source\GridControl\XTPGridADO.h(1422): error: enumeration previously declared with fixed underlying type 1422 | enum SearchDirectionEnum | ^ C:\Program Files (x86)\Codejock Software\MFC\Xtreme ToolkitPro v22.1.0\Source\GridControl\XTPGridADO.h(1073): message: previous declaration is here 1073 | XTP_FORWARD_ENUM(SearchDirectionEnum); | Related to that, I found this information: https://timsong-cpp.github.io/cppwp/n4140/dcl.enum#3 The issue here seems to be the definition of the XTP_FORWARD_ENUM, found in Source\Common\XTPMacros.h: # if (1700 <= _MSC_VER) # define XTP_DECLARE_ENUM(enumName) enum enumName : int # else # define XTP_DECLARE_ENUM(enumName) enum enumName # endif # define XTP_FORWARD_ENUM(enumName) XTP_DECLARE_ENUM(enumName) My compiler is a lot newer than 1700, thus the enums are forward declared with int datatype. Afterwards though, they are redeclared without the int datatype, which is causing the error. My solution would be to change the definition of those four enums (the solution applies to all four of them, thus tagDOMNodeType, tagXMLEMEM_TYPE, PositionEnum, SearchDirectionEnum) from: enum PositionEnum { ... } to: # if (1700 <= _MSC_VER) enum PositionEnum : int # else enum PositionEnum # endif { ... } This fixes the compilation for me. Thanks in advance.
|
|
astoyan
Admin Group Joined: 24 August 2013 Status: Offline Points: 304 |
Post Options
Thanks(0)
|
Hello,
ToolkitPro never had official support for Clang compiler, it has always aimed for MSVC support only and it relies heavily on its specific, so adding Clang support isn't going to be an easy task for sure, if possible at all. At least taking this step would require a major demand from ToolkitPro user base, however it's not the case. If you want to clang-tidy your project then you simply need to exclude ToolkitPro from this process, even if those fixes will make it work for now, there is no guarantee that it will be working in the future versions of all tools involved. Regards, Alexander
|
|
jkmgs
Newbie Joined: 25 September 2023 Status: Offline Points: 5 |
Post Options
Thanks(0)
|
Hi Alexander,
Thanks for the reply. Sad to hear that Clang support is not important as of now. However, this does not change the problem that exists in the source code for which I provided a potential solution above. I don't know if you took a look at the link I included above, but they state: "A scoped enumeration shall not be later redeclared as unscoped or with a different underlying type. An unscoped enumeration shall not be later redeclared as scoped and each redeclaration shall include an enum-base specifying the same underlying type as in the original declaration.". This is exactly what is done in the source code though as shown above. So this problem is a general C++ problem and not specific to any compiler, thus it is as relevant for MSVC compiler as it is for Clang. So a solution would be greatly appreciated. Best regards, Johannes
|
|
jkmgs
Newbie Joined: 25 September 2023 Status: Offline Points: 5 |
Post Options
Thanks(0)
|
Hi,
Any updates on this? Would appreciate it if this problem can be fixed. Best regards, Johannes
|
|
jkmgs
Newbie Joined: 25 September 2023 Status: Offline Points: 5 |
Post Options
Thanks(0)
|
Hi,
The latest version v24.0.0 (Beta 1) still did not fix those issues. Please fix them. To summarize, in the file XTPXMLHelpers.h, the following has to be adapted: Line 207: enum tagDOMNodeType to # if (1700 <= _MSC_VER) enum tagDOMNodeType : int # else enum tagDOMNodeType # endif Line 740: enum tagXMLEMEM_TYPE to # if (1700 <= _MSC_VER) enum tagXMLEMEM_TYPE : int # else enum tagXMLEMEM_TYPE # endif Furthermore, in the file XTPScrollable.h change: Line 479: return CXTPScrollHost::InitializeScrollHost(this, CObject::GetStyle(), CObject::GetExStyle()); to return CXTPScrollHost::InitializeScrollHost(this, CWnd::GetStyle(), CWnd::GetExStyle()); or return CXTPScrollHost::InitializeScrollHost(this, GetStyle(), GetExStyle()); Best regards, Johannes |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |