Recently I upgraded my SourcePro to 2021 Version and during RCB setup when it prompts me to select C++ dialect, I selected the only option available i.e. C++14. After the setup I started compiling Tuxedo code and currently facing the following errors in multiple files say about 200-250 files in my Tuxedo project, and below are the details of my Solaris OS and the compiler.
uname -a:
SunOS nzdrb12z 5.11 11.4.40.107.3 sun4v sparc sun4v non-global-zone
cc -V:
cc: Studio 12.6 Sun C 5.15 SunOS_sparc 2017/05/30
Error: app/sdasup/home/mhp/source/develop/bc/include/bcIControlBlock.h", line 34: Error: Narrowing conversion of 'int' value to 'short' is not allowed here. "/app/sdasup/home/mhp/source/develop/bc/include/bcIPControlBlockTran.h", line 48: Error: Narrowing conversion of 'int' value to 'short' is not allowed here. "/app/sdasup/home/mhp/source/develop/bc/include/bcIPConnectionParam.h", line 44: Error: Narrowing conversion of 'int' value to 'short' is not allowed here. "/app/sdasup/home/mhp/source/develop/bc/include/bcMwServicesGuid.h", line 15: Error: Narrowing conversion of 'int' value to 'short' is not allowed here. "/app/sdasup/home/mhp/source/develop/bc/include/bcMwServicesGuid.h", line 34: Error: Narrowing conversion of 'int' value to 'short' is not allowed here. "/app/sdasup/home/mhp/source/develop/bc/include/bcMwServicesGuid.h", line 36: Error: Narrowing conversion of 'int' value to 'short' is not allowed here. "/app/sdasup/home/mhp/source/develop/bc/include/bcMwServicesGuid.h", line 41: Error: Narrowing conversion of 'int' value to 'short' is not allowed here. "/app/sdasup/home/mhp/source/develop/bc/include/bcMwServicesGuid.h", line 45: Error: Narrowing conversion of 'int' value to 'short' is not allowed here.
Suppose I chose the first error message file to open bcIControlBlock.h and the line number 34 points to the following code,
DEFINE_GUID(IID_IAbcIControlBlock, 0xc7645022, 0x93e9, 0x11d1, 0x9d, 0x90, 0x0, 0x0, 0xf6, 0x4e, 0x16, 0x6a);
when searched for the Macro it has following definition,
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
EXTERN_C const GUID name \
= { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
As a workaround I tired the following to solve it,
DEFINE_GUID(IID_IAbcIControlBlock, 0xc7645022, (short)0x93e9, 0x11d1, 0x9d, 0x90, 0x0, 0x0, 0xf6, 0x4e, 0x16, 0x6a);
Albeit it works fine I am very doubtful on the approach I followed to resolve the issue. However changing multiple files seems to be painful.
Quesitons:
Thanks in advance.
Ideally, all GUID
fields should be declared unsigned (see for instance this Microsoft documentation). But some languages (Java, for instance) don't support unsigned integers. So it looks like your C++ GUID
structure was defined by a Java programmer.
If you can change the definition of GUID
, do that. If not, I am afraid you are going to have to apply your (short)
cast to all occurrences of the DEFINE_GUID
macro (unless your compiler has some way of disabling this error, as suggested in the comments to your original post). Java programmers have to do this all the time.