Search code examples
c++clangclang++unlink

Does clang provide an unlink implementation?


I am trying to compile a library using clang. The library makes calls to 'unlink', which is not defined by clang:

libmv/src/third_party/OpenExif/src/ExifImageFileWrite.cpp:162:17: error: use of undeclared identifier 'unlink'; did you mean 'inline'?
            unlink( mTmpImageFile.c_str() ) ;

My question is, what is the clang equivalent of unlink? As I see it, the path forward would be to #define unlink somewhere with an equivalent routine.


Solution

  • There is no "Clang equivalent". Neither GCC nor Clang have ever been responsible for defining unlink, though they do probably distribute the POSIX headers which do (I don't recall specifically where POSIX headers come from).

    Unfortunately, this appears to be a bug with the library you're using; the OpenExif developers failed to include the correct headers. Different C++ implementations may internally #include various headers for their own purposes, which has apparently masked this bug on your previous toolchain.

    You can hack your copy and/or submit a patch to add:

    #include <unistd.h>