Lorenzo Bettini wrote: > I tried it and got no problem, but as far as I understand this is not a > proof, since > > #if defined HAVE_DECL_STRDUP && !HAVE_DECL_STRDUP && !defined strdup > /* Duplicate S, returning an identical malloc'd string. */ > extern char *strdup (const char *s); > #endif > > so the extern definition is not parsed, since it finds the definition of > strdup in string.h (included in strdup.h).
Yes, the absence of a failure doesn't prove anything. > However, I tried this test program: > > #include <iostream> > > extern char *strdup (const char *s); > > int main() > { > char *copy = strdup("foobar"); > std::cout << copy << std::endl; > > return 0; > } > > and got no problem This doesn't prove anything either: <iostream> may include <string.h>, which may have an extern "C" declaration for strdup. Can you tell us the list of .h files that you want to use from C++? It's easier to make them C++ safe than to consider when exactly the extern "C" will be needed or not. Bruno