Print Page | Close Window

Clang compile error - enumeration previously ...

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=24427
Printed Date: 26 December 2024 at 2:54pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Clang compile error - enumeration previously ...
Posted By: jkmgs
Subject: Clang compile error - enumeration previously ...
Date 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" rel="nofollow - 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.



Replies:
Posted By: astoyan
Date Posted: 25 September 2023 at 9:53am
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


Posted By: jkmgs
Date Posted: 26 September 2023 at 3:33am
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  https://timsong-cpp.github.io/cppwp/n4140/dcl.enum#nt:enum-base" rel="nofollow - 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


Posted By: jkmgs
Date Posted: 25 January 2024 at 5:08am
Hi,

Any updates on this? Would appreciate it if this problem can be fixed.

Best regards,
Johannes


Posted By: jkmgs
Date Posted: 03 July 2024 at 6:44am
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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net