简体   繁体   中英

`dirent.h` in multiple directories

I searched dirent to find C routines

find / -iregex ".*/dirent.h$" 2>/dev/null

Which return series of identical ones

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/dirent.h
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/dirent.h
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/dirent.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/dirent.h

How could I ensure which dirent.h is the one my program invoke?

If you get the compiler to show you the code after pre-processing, you should be able to work it out.

So, for example, with gcc , you can write a nominal program.c :

#include <dirent.h>
main(int argc, char **argv){
    return 0;
}

And then run:

gcc -E program.c

and study what it includes.

Related useful info here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM