[LibC++] Incompatibility between '<stdio.h> from LibC++ v5.0's ' Newlib v2.5.0, and a workaround/fix

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[LibC++] Incompatibility between '<stdio.h> from LibC++ v5.0's ' Newlib v2.5.0, and a workaround/fix

Eric Fiselier via cfe-dev

I have been working on stabilising our out-of-tree sources following the upgrade to the v5.0 Final Release, and came across an incompatibility between the ‘<stdio.h>’ provided with Newlib v2.5.0 and the one provided with LibC++ v5.0.

 

The problem is how LibC++ handles the ‘getc’ and ‘putc’ implementations, and if these are defined it uses a shim, then ‘#undef’s the original, and redefines them as functions.

 

In general this is a good strategy, but in this case ‘getc’ and ‘putc’ are both declared as external functions, and subsequently defined as macros.  When LibC++ undefines these macros and defines the functions ‘getc’ and ‘putc’, it does so appending ‘_NOEXCEPT’ and this causes a multiple definition conflict with the declaration in Newlib’s ‘<stdio.h>’ which does not have this appended.

 

My workaround was to rewrite these as:

 

#ifndef __NEWLIB__

int getc(FILE *__lcpp_x) _NOEXCEPT {

#else

int getc(FILE *__lcpp_x)

#endif

and:

#ifndef __NEWLIB__

int petc(int __lcpp_x, FILE *__lcpp_y) _NOEXCEPT {

#else

int petc(int __lcpp_x, FILE *__lcpp_y)

#endif

 

All the best,

 

            MartinO

 

 

--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: [LibC++] Incompatibility between '<stdio.h> from LibC++ v5.0's ' Newlib v2.5.0, and a workaround/fix

Eric Fiselier via cfe-dev
On 9/21/2017 8:07 AM, ORiordan, Martin via cfe-dev wrote:

I have been working on stabilising our out-of-tree sources following the upgrade to the v5.0 Final Release, and came across an incompatibility between the ‘<stdio.h>’ provided with Newlib v2.5.0 and the one provided with LibC++ v5.0.

 

The problem is how LibC++ handles the ‘getc’ and ‘putc’ implementations, and if these are defined it uses a shim, then ‘#undef’s the original, and redefines them as functions.


Please specify which file, on which branch, you're talking about.  As far as I can tell, libc++ hasn't included a wrapper for putc since r249475 (roughly two years ago).

-Eli
-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: [LibC++] Incompatibility between '<stdio.h> from LibC++ v5.0's ' Newlib v2.5.0, and a workaround/fix

Eric Fiselier via cfe-dev

Hi Eli,

 

The “wrapper” is called ‘libcxx/include/stdio.h’, but I think that I have managed to get an SVN merge problem that is not properly resolved (though how far back I cannot tell) as I can clearly see that the new wrapper version of ‘<stdio.h>’ is a lot simpler than the one I have so this is a false negative.  My apologies.

 

Thanks,

 

            MartinO

 

From: cfe-dev [mailto:[hidden email]] On Behalf Of Friedman, Eli via cfe-dev
Sent: 21 September 2017 19:36
To: ORiordan, Martin <[hidden email]>; Clang Dev <[hidden email]>
Subject: Re: [cfe-dev] [LibC++] Incompatibility between '<stdio.h> from LibC++ v5.0's ' Newlib v2.5.0, and a workaround/fix

 

On 9/21/2017 8:07 AM, ORiordan, Martin via cfe-dev wrote:

I have been working on stabilising our out-of-tree sources following the upgrade to the v5.0 Final Release, and came across an incompatibility between the ‘<stdio.h>’ provided with Newlib v2.5.0 and the one provided with LibC++ v5.0.

 

The problem is how LibC++ handles the ‘getc’ and ‘putc’ implementations, and if these are defined it uses a shim, then ‘#undef’s the original, and redefines them as functions.


Please specify which file, on which branch, you're talking about.  As far as I can tell, libc++ hasn't included a wrapper for putc since r249475 (roughly two years ago).

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev