Undefined reference to 'select()'

David Cuthbert dacut at kanga.org
Sun Jun 18 00:56:18 PDT 2006


walt wrote:
Just for fun I added this prototype to the code:
extern "C" int select(int, fd_set*, fd_set*, fd_set*, struct timeval*);
Now I get complaints from <sys/select.h> about duplicate definitions
of select()  :o(
This indicates that sys/select.h should be wrapped in the extern "C". 
Sounds like this got removed from a recent commit.

In general, all headers for C functions should look like:

#ifndef MY_HEADER
#define MY_HEADER
#include <blah.h>
#include ...
#ifdef __cplusplus
extern "C" {
#endif
void my_function();

#ifdef __cplusplus
}
#endif
#endif /* MY_HEADER */





More information about the Bugs mailing list