Compile error current master

Herbert Thoma herbert.thoma at iis.fraunhofer.de
Sat Apr 26 12:01:09 EDT 2014


Am 26.04.2014 16:25, schrieb John Ralls:
>
> On Apr 26, 2014, at 3:25 AM, Herbert Thoma <herbert.thoma at iis.fraunhofer.de> wrote:
>> BTW: if I supply --disable-error-on-warning to configure, it does not get much
>> further:
>>
>> kvp_frame.c: In function 'KvpFrame* get_trailer_make(KvpFrame*, const char*, char**)':
>> kvp_frame.c:329:38: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
>> kvp_frame.c: In function 'const KvpFrame* get_trailer_or_null(const KvpFrame*, const char*, char**)':
>> kvp_frame.c:371:38: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
>> make[5]: *** [libgnc_qof_la-kvp_frame.lo] Error 1
>>
>> C++ is much stricter with types than plain C ...
>
> Indeed. One of its features.
>
> Apparently you have a defective string.h: The lines in question are
>        last_key = strrchr (key_path, '/');
>
> and strrchr is declared as
>        char* strrchr(const char *, int);
> in the POSIX standard [1]. 'key_frame' is the 'const char*' argument in the function arguments.

Hmm, I would guess that I should have a pretty standard glibc
(version 2.17).

Anyway, this is the relevant section in my /usr/include/string.h:

/* Find the last occurrence of C in S.  */
#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
extern "C++"
{
extern char *strrchr (char *__s, int __c)
      __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1));
extern const char *strrchr (const char *__s, int __c)
      __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1));

# ifdef __OPTIMIZE__
__extern_always_inline char *
strrchr (char *__s, int __c) __THROW
{
   return __builtin_strrchr (__s, __c);
}

__extern_always_inline const char *
strrchr (const char *__s, int __c) __THROW
{
   return __builtin_strrchr (__s, __c);
}
# endif
}
#else
extern char *strrchr (const char *__s, int __c)
      __THROW __attribute_pure__ __nonnull ((1));
#endif
__END_NAMESPACE_STD


Well, I do not understand all the preprocessor magic and I don't know
which macros are defined, but obviously there are some declarations
of strrchr with const and some without ...

But since this is standard glibc, it should simply work ...

  Herbert

> I can const_cast<char*>(key_frame) in there, but I'd rather not.
>
> Regards,
> John Ralls
>
>
> [1] http://pubs.opengroup.org/onlinepubs/009695299/functions/strrchr.html
>


More information about the gnucash-devel mailing list