[Bug 268820] index C++ variable overloading

[email protected]
Newsgroups gmane.os.freebsd.devel.standards
Message-ID <[email protected]/bugzilla/>
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268820

Mark Millard <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #1 from Mark Millard <[email protected]> ---
FYI: The specific error report is:

# c++ string_index_use.cpp 
string_index_use.cpp:3:13: error: redefinition of 'index' as different kind of
symbol
std::string index;
            ^
/usr/include/strings.h:62:7: note: previous definition is here
char    *index(const char *, int) __pure;                       /* LEGACY */
         ^
1 error generated.

for:

# more string_index_use.cpp
#include <string>

std::string index;

int main() {

}

I get the same for stable/13 and main [so: 14].

For reference, for the __BEGIN_DECLS related use in strings.h :

# grep -r "define.*__BEGIN_DECLS" /usr/include/
/usr/include/sys/cdefs.h:#define        __BEGIN_DECLS   extern "C" {
/usr/include/sys/cdefs.h:#define        __BEGIN_DECLS

and the code block is:

#if defined(__cplusplus)
#define __BEGIN_DECLS   extern "C" {
#define __END_DECLS     }
#else
#define __BEGIN_DECLS
#define __END_DECLS
#endif

The strings.h is used via /usr/include/string.h by the text:

. . .
#include <sys/cdefs.h>
#include <sys/_null.h>
#include <sys/_types.h>

/*
 * Prototype functions which were historically defined in <string.h>, but
 * are required by POSIX to be prototyped in <strings.h>.
 */
#if __BSD_VISIBLE
#include <strings.h>
#endif
. . .

So __BSD_VISIBLE in involved in causing the extra definition
of index.

-- 
You are receiving this mail because:
You are the assignee for the bug.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.