string.h and std_cstring.h

Graeme Peterson gp@qnx.com
Fri Aug 2 14:11:00 GMT 2002


Hi, all.

I am working on the QNX i386-nto support in gcc again.

The current stumbling block is that our string.h declares
memchr, strchr, strpbrk, strrchr, and strstr as inline.

So does libstdc++-v3/include/c_std/std_cstring.h.  This
cause libstdc++ to not build.  

It seems to me that std_cstring.h is assuming that these 
functions will always be macros, and that this is not always
true.

If I wrap the definitions in std_cstring.h with an ifdef, and
then undef them and declare them inline, things work.

ie: (similarly for the other 4)

	#ifdef memchr
	#undef memchr  // moved from the top of the file

	using ::memchr;
	
	inline void*
	memchr(void* __p, int __c, size_t __n)
	{ return memchr(const_cast<const void*>(__p), __c, __n); }
	#endif


I also tried renaming the inline functions in our string.h to be
"__ntomemchr", etc..., and then defining macros:

	#define memchr __ntomemchr
	etc...

This met with limited success, as our memchr declaration returns
"const void*", where gcc's is "void *", and the build failed with:

	error: invalid conversion from `const void*' to `void*'



Comments?  Am I missing something?

Thanks.
Regards,
GP



More information about the Gcc mailing list