http://d.puremagic.com/issues/show_bug.cgi?id=5206
Summary: stat_t is not the same as struct stat Product: D Version: D2 Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nob...@puremagic.com ReportedBy: jesse.k.phillip...@gmail.com CC: jesse.k.phillip...@gmail.com --- Comment #0 from Jesse Phillips <jesse.k.phillip...@gmail.com> 2010-11-11 21:34:53 PST --- The structure created by D for stat is not the same size as the one in C, and there appears to be no communication of data between C and D. Assigns a value to st_mode and calls a C function which prints the value and assigns its own. At which point D prints the value (the same one it assigned). Running 32bit Linux. Output: D size: 100 D Assigning 65 C Size: 88 C Found: 0 C Assign: 45 D Found 65 import core.sys.posix.sys.stat; import std.stdio; extern(C) void modStat(stat_t* data); void main() { stat_t stbuf; writeln("D size: ", stbuf.sizeof); writeln("D Assigning ", 65); stbuf.st_mode = 65; modStat(&stbuf); writeln("D Found ", stbuf.st_mode); } --------------- cstat.c #include <sys/stat.h> #include <stdio.h> void modStat(struct stat *stbuf) { struct stat rrr; printf("C Size: %d\n", sizeof(rrr)); printf("C Found: %d\n", stbuf->st_mode); printf("C Assign: %d\n", 45); stbuf->st_mode = 45; } Compiled with: gcc -g -c cstat.c && dmd -gc stat.d cstat.o -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------