Fixes are available
March 2009 Update for XL C/C++ for Linux, V10.1
October 2009 Update for XL C/C++ for Linux, V10.1
June 2011 Update for XL C/C++ for Linux, V10.1
XL C/C++ for Linux Fix Pack 8 (January 2014 Update) for 10.1
August 2010 Update for XL C/C++ for Linux, V10.1
January 2011 Update for XL C/C++ for Linux, V10.1
January 2012 Update for XL C/C++ for Linux, V10.1
July 2012 Update for XL C/C++ for Linux, V10.1
APAR status
Closed as program error.
Error description
Problem: A friend declaration inside of a class inside of a namespace inside of an extern "C" block is incorrectly generating an error. =====Start of a.C====== extern "C" { namespace N { struct A { friend void foo(); }; } } ==========End of a.C============== $xlC -c a.C "a.C", line 4.19: 1540-0434 (S) The friend function must also be declared in the enclosing block scope.
Local fix
You can also use a work around to solve the problem. The original code had extern "C" around everything (i.e. the namespace and class definition). This is overkill and can be confusing since the member functions have to follow the C++ linkage. If it is feasible you can look at changing the source code to something more accurate. See the following example. This gives you an alternate to waiting for an interim compiler fix. The work around is still valid C++ code and should be compiled by other compilers too. -- a-fix.C namespace N { extern "C" { void foo(); } struct A { friend void foo(); }; } -- a-fix.C -- This work around is more typical C++ code. You should have better luck porting it from compiler to compiler.
Problem summary
Users who want to have a friend declaration inside a class/struct inside of a namespace inside of an extern "C" block. An incorrect error was generated. The original intent of the error is to catch friend declaration inside a local class (without prior declaration). We incorrectly applied the same check on a namespace inside of an extern "C" block.
Problem conclusion
Additional if statements are in place to distinguish a local class from a namespace inside of an extern "C" block before the check.
Temporary fix
Comments
APAR Information
APAR number
LI74403
Reported component name
XL C/C++ RHEL52
Reported component ID
5724U8310
Reported release
A10
Status
CLOSED PER
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt
Submitted date
2009-03-31
Closed date
2009-03-31
Last modified date
2009-03-31
APAR is sysrouted FROM one or more of the following:
APAR is sysrouted TO one or more of the following:
Fix information
Fixed component name
XL C/C++ RHEL52
Fixed component ID
5724U8310
Applicable component levels
RA10 PSN LI74341
UP06/09/13
[{"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSJT9L","label":"XL C\/C++"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"A.1","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]
Document Information
Modified date:
16 October 2021