I'm having the following code:
import core.sys.posix.sys.stat;
int is_dir(const char* path) {
stat_t s;
if (stat(path, &s) == 0) {
if (S_ISDIR(s.st_mode)) return 1;
else return 0;
} else return 2;
}
int is_regf(const char* path) {
stat_t s;
if (stat(path, &s) == 0) {
if (S_ISREG(s.st_mode)) return 1;
else return 0;
} else return 2;
}
extern (C) void main() {
is_dir("/lol");
is_regf("/tmp");
}
When I try to compile this code using "ldc2" and "dmd", I'm getting the following message (the "format" is different between the compilers tho):
estd.o:test.d:function _D4test6is_dirFxPaZi: error: undefined reference to '_D4core3sys5posixQk4stat7S_ISDIRFNbNikZb'
testd.o:test.d:function _D4test7is_regfFxPaZi: error: undefined reference to '_D4core3sys5posixQk4stat7S_ISREGFNbNikZb'
If I open the file from the "stat" module (in my linux system it's in "/usr/include/dlang/ldc/core/sys/posix/sys/stat.d"), I will see that these functions do exists and the weird thing is that it will work if I don't compile using the "-betterC" option but it will not if I do. If I'm not mistaken, "core*" should work with "-betterC". Any ideas?