[cfe-users] clang cannot find header file for lstat?

Hongxu Chen leftcopy.chx at gmail.com
Tue Oct 29 01:55:43 PDT 2013

I think this is a trivial question, but I just don't know why.

When clang compile the following snippets, it complains that there is no
definition for 'lstat'.

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <assert.h>

int main(int argc, char** argv) {
  assert(argc > 1);
  struct stat buf;
  stat(argv[1], &buf);
  printf("%u\n", buf.st_mode);
  lstat(argv[1], &buf);
  printf("%u\n", buf.st_mode);
  return 0;

However it compiles without any warnings when using gcc, and I can see the
declaration of lstat in sys/stat.h.

Is it because the certain macro definition hides the declaration of lstat
when compiling using clang?

The clang version is 3.4 svn186209 and I'm on an x86_64 machine running on
Ubuntu 12.04 LTS.

Hongxu Chen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20131029/2a599a0c/attachment.html>

More information about the cfe-users mailing list