Why is there no cdirent or sys/cstat
c, c++, linux
Solution
`dirent.h` and `sys/stat.h` are POSIX/SUS headers rather than standard C/C++ headers, and as such do not adhere to the standard C++ rules.
Problem
I was writing a C++ code that iterates through all the entries of a directory and decided to use dirent.h. Since I was using C++, I decided to use the C++ standard for including C library files [i.e. prefixing the library name with c and removing the .h at the end] Without adding any functionality I decided to compile my program once to see if there was actually a `cdirent` or `sys/cstat`. g++ threw an error telling me that these files where not present ``` #include <iostream> #include <cdirent> #include <sys/cstat> #include <sys/ctypes> using namespace std; int main() { } dummy.cpp:2:19: error: cdirent: No such file or directory dummy.cpp:3:21: error: sys/cstat: No such file or directory dummy.cpp:4:22: error: sys/ctypes: No such file or directory ``` Following the advice given in this page on where to look for standard C++ header files I could locate `cstdio`, `cstdlib`, `ctime` and the like which brings me to my questions - When is a C standard library file converted to a C++ standard library file? - How should one include such files in the program? The page here only talks about standard and non standard header files. But I believe `dirent.h` is a standard library file [Correct me if I am wrong] Thanks in advance for all the suggestions