mercredi 2 mars 2022

Narrowing conversion of 'int' value to 'short' is not allowed here

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:

  1. Is the workaround solution correct?
  2. If so then how it can be made more general to change it at one place than multiple files?
  3. If not what is best approach to resolve so that it wont break anything further?

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire