On 10/15/2012 05:00 AM, Ian Lance Taylor wrote:
> On Sat, Oct 13, 2012 at 1:11 PM, Andreas Schwab <sch...@linux-m68k.org> wrote:
>> Ian Lance Taylor <i...@google.com> writes:
>>
>>> Suppose you drop this into include/libiberty.h:
>>>
>>> #ifdef __cplusplus
>>> inline char *lbasename(char *s) { return const_cast<char*>(lbasename (s)); }
>>> #endif
>>
>> That doesn't work:
>>
>> ../../gcc/libcpp/../include/libiberty.h: In function ‘char* 
>> lbasename(char*)’:
>> ../../gcc/libcpp/../include/libiberty.h:123:31: error: declaration of C 
>> function ‘char* lbasename(char*)’ conflicts with
>> ../../gcc/libcpp/../include/libiberty.h:121:20: error: previous declaration 
>> ‘const char* lbasename(const char*)’ here
> 
> Hmmm, of course.

Wrapping with extern "C++" makes it work:

#ifdef __cplusplus
extern "C++"
{
inline char *lbasename(char *s) { return const_cast<char*>(lbasename (s)); }
}
#endif

> 
> OK, your patch with CONST_CAST is OK.
> 
> Thanks.
-- 
Pedro Alves

Reply via email to