Highlighted
Absent Member.
Absent Member.
1709 views

comp-5 redefination

Jump to solution

Release: Net Express 5.1 .NET & Visual Studio 2012

While compiling the source from NE5.1 in Visual COBOL 2.2.1, we are receiving a warning for comp-5 redefinition.

The vaiables are defined as follows: 

               01  WS-MENU-ID      PIC S9(4) COMP-5.

               01  WS-FIELD-KEY REDEFINES WS-MENU-ID

                                       PIC S9(4) COMP-5.

               01  WS-BUTTON-ID REDEFINES WS-MENU-ID

                                       PIC S9(4) COMP-5.

This returns a warning about using this COMP-5 redefintion. Is there any way to remove these warnings? I do not want to suppress them. What are the implications it will have in code.

0 Likes
2 Solutions

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: comp-5 redefination

Jump to solution

Hello anveksha,

Net Express and Visual COBOL report the exact same warning, but the difference is that Net Express is not reporting warnings by default while Visual COBOL (IDE) is.

The WARNING compiler directive is set to 1 by default in Net Express, and it is set to 2 in Visual COBOL (IDE).

See more details from the documentation here

Regards,

–Ғɑɳօ

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: comp-5 redefination

Jump to solution

In your particular case, there are no implications because you have simply defined three-names for the same data item.  The documentation for error 1168 is:

          You have redefined a COMP-5 data item. Porting your code to other environments

               might produce inconsistent results.

Redefinition that doesn't define exactly the same COMP-5 data item could be non-portable between machines with different memory architecture, such as Intel versus IBM.  Thus, the warning; most of COBOL is portable between machine architectures.  COMP-5 is native machine byte order, which differs between machines.  The redefinition starts at the left-most byte, which might be the high-order byte (IBM) or the low-order byte (Intel).  This won't matter when the definitions are for the same data item description, as in your case.  However, REDEFINES allows for the case of the data items being described differently.  One could argue that the compiler should allow your case without a warning, but the compiler does not normally go to this level of analysis just to suppress a warning.

View solution in original post

0 Likes
3 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: comp-5 redefination

Jump to solution

Hello anveksha,

Net Express and Visual COBOL report the exact same warning, but the difference is that Net Express is not reporting warnings by default while Visual COBOL (IDE) is.

The WARNING compiler directive is set to 1 by default in Net Express, and it is set to 2 in Visual COBOL (IDE).

See more details from the documentation here

Regards,

–Ғɑɳօ

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: comp-5 redefination

Jump to solution

In your particular case, there are no implications because you have simply defined three-names for the same data item.  The documentation for error 1168 is:

          You have redefined a COMP-5 data item. Porting your code to other environments

               might produce inconsistent results.

Redefinition that doesn't define exactly the same COMP-5 data item could be non-portable between machines with different memory architecture, such as Intel versus IBM.  Thus, the warning; most of COBOL is portable between machine architectures.  COMP-5 is native machine byte order, which differs between machines.  The redefinition starts at the left-most byte, which might be the high-order byte (IBM) or the low-order byte (Intel).  This won't matter when the definitions are for the same data item description, as in your case.  However, REDEFINES allows for the case of the data items being described differently.  One could argue that the compiler should allow your case without a warning, but the compiler does not normally go to this level of analysis just to suppress a warning.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: comp-5 redefination

Jump to solution

Thanks Bruce and MF_Fano..

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.