This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[patch] make sure strings.h gets used if __USE_BSD is not defined


This program will give warnings about undefined reference to
strcasecmp(). The logic in string.h and strings.h is that the strings.h
declerations are not used if string.h was already included. This breaks
when __USE_BSD isn't defined, since the definitions in string.h depend
on that interface. So, this patch makes it round out that logic.

#define _XOPEN_SOURCE 500
#include <string.h>
#include <strings.h>

int main(void) {
    return strcasecmp("asdf", "asdf");
}
strcasecmp-test.c:6: warning: implicit declaration of function `strcasecmp'

I can come up with a test for all of the functions in strings.h under this
situation, if you think it's needed. There might actually need to be
some better coherency between these two files. Would it be better to
have something like this in string.h:

#ifdef __USE_BSD
#include <strings.h>
#endif

??

2001-01-01  Ben Collins  <bcollins@debian.org>

	* string/strings.h: Make sure we declare our functions even if
	  string.h is already included, based on whether or not
	  __USE_BSD is defined.

-- 
 -----------=======-=-======-=========-----------=====------------=-=------
/  Ben Collins  --  ...on that fantastic voyage...  --  Debian GNU/Linux   \
`  bcollins@debian.org  --  bcollins@openldap.org  --  bcollins@linux.com  '
 `---=========------=======-------------=-=-----=-===-======-------=--=---'
Index: string/strings.h
===================================================================
RCS file: /cvs/glibc/libc/string/strings.h,v
retrieving revision 1.10
diff -u -u -r1.10 strings.h
--- strings.h	2000/05/17 12:18:53	1.10
+++ strings.h	2001/01/02 07:31:46
@@ -20,11 +20,14 @@
 #define	_STRINGS_H	1
 
 /* We don't need and should not read this file if <string.h> was already
-   read.  */
-#ifndef _STRING_H
+   read. The one exception being that if __USE_BSD isn't defined, then
+   these aren't defined in string.h, so we need to define them here.  */
+#if !defined(_STRING_H) || !defined(__USE_BSD)
 
 # include <features.h>
-# define __need_size_t
+# ifndef __need_size_t
+#  define __need_size_t
+# endif
 # include <stddef.h>
 
 __BEGIN_DECLS

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]