Forum Navigation
Several issues - posix.unistd, core.Memory
Posted: 04/08/08 18:55:14hm, not my day I guess :)
first things first, following code then errors
1.
module gc_test; import tango.io.Stdout; import tango.stdc.posix.unistd; class A { int x; this() { Stdout.formatln("Calling constructor of A"); } ~this() { Stdout.formatln("Calling destructor of A"); } } void main() { A foo = new A; usleep(50000); sleep(5); } /* C:\d_programming\tango\import\tango\stdc\posix\unistd.d(30): Error: identifier 'uid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(30): Error: uid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(30): Error: cannot have parameter of type void C:\d_programming\tango\import\tango\stdc\posix\unistd.d(30): Error: identifier 'gid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(30): Error: gid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(30): Error: cannot have parameter of type void C:\d_programming\tango\import\tango\stdc\posix\unistd.d(42): Error: identifier 'uid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(42): Error: uid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(42): Error: cannot have parameter of type void C:\d_programming\tango\import\tango\stdc\posix\unistd.d(42): Error: identifier 'gid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(42): Error: gid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(42): Error: cannot have parameter of type void C:\d_programming\tango\import\tango\stdc\posix\unistd.d(43): Error: identifier 'pid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(43): Error: pid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(45): Error: identifier 'off_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(45): Error: off_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(45): Error: cannot have parameter of type void C:\d_programming\tango\import\tango\stdc\posix\unistd.d(47): Error: identifier 'gid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(47): Error: gid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(48): Error: identifier 'uid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(48): Error: uid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(49): Error: identifier 'gid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(49): Error: gid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(50): Error: identifier 'gid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(50): Error: gid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(55): Error: identifier 'pid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(55): Error: pid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(56): Error: identifier 'pid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(56): Error: pid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(57): Error: identifier 'pid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(57): Error: pid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(58): Error: identifier 'uid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(58): Error: uid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(61): Error: identifier 'off_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(61): Error: off_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(61): Error: identifier 'off_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(61): Error: off_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(61): Error: cannot have parameter of type void C:\d_programming\tango\import\tango\stdc\posix\unistd.d(65): Error: identifier 'ssize_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(65): Error: ssize_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(66): Error: identifier 'ssize_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(66): Error: ssize_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(68): Error: identifier 'gid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(68): Error: gid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(68): Error: cannot have parameter of type void C:\d_programming\tango\import\tango\stdc\posix\unistd.d(69): Error: identifier 'uid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(69): Error: uid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(69): Error: cannot have parameter of type void C:\d_programming\tango\import\tango\stdc\posix\unistd.d(70): Error: identifier 'gid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(70): Error: gid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(70): Error: cannot have parameter of type void C:\d_programming\tango\import\tango\stdc\posix\unistd.d(71): Error: identifier 'pid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(71): Error: pid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(71): Error: cannot have parameter of type void C:\d_programming\tango\import\tango\stdc\posix\unistd.d(71): Error: identifier 'pid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(71): Error: pid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(71): Error: cannot have parameter of type void C:\d_programming\tango\import\tango\stdc\posix\unistd.d(72): Error: identifier 'pid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(72): Error: pid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(73): Error: identifier 'uid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(73): Error: uid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(73): Error: cannot have parameter of type void C:\d_programming\tango\import\tango\stdc\posix\unistd.d(77): Error: identifier 'pid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(77): Error: pid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(78): Error: identifier 'pid_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(78): Error: pid_t is used as a type C:\d_programming\tango\import\tango\stdc\posix\unistd.d(78): Error: cannot have parameter of type void C:\d_programming\tango\import\tango\stdc\posix\unistd.d(82): Error: identifier 'ssize_t' is not defined C:\d_programming\tango\import\tango\stdc\posix\unistd.d(82): Error: ssize_t is used as a type */this is what I found in tango.stdc.posix.sys.types:
// // Required // /* blkcnt_t blksize_t dev_t gid_t ino_t mode_t nlink_t off_t pid_t size_t ssize_t time_t uid_t */so, umm wth? how am I supposed to use sleep then? For now I'm using Thread.sleep
next issue
2.
module gc_test; import tango.io.Stdout; import tango.core.Thread; class A { int x; this() { Stdout.formatln("Calling constructor of A"); } ~this() { Stdout.formatln("Calling destructor of A"); } } void main() { A foo = new A; Thread.sleep(2); A bar = new A; Thread.sleep(2); }output is:
Calling constructor of A Calling constructor of A Calling destructor of AI believe there should be two calls for destructor, no?
and a variation on the theme which confuses me the most:
module gc_test; import tango.io.Stdout; import tango.core.Thread; import tango.core.Memory; class A { int x; this() { Stdout.formatln("Calling constructor of A"); } ~this() { Stdout.formatln("Calling destructor of A"); } } void main() { GC.disable(); A foo = new A; Thread.sleep(2); A bar = new A; Thread.sleep(2); }output is the same as previous, I though now there shouldn't be ANY call to destructor, or if there is (exiting application scope) there should be, again, two of them, no?
and finally:
module gc_test; import tango.io.Stdout; import tango.core.Thread; import tango.core.Memory; class A { int x; this() { Stdout.formatln("Calling constructor of A"); } ~this() { Stdout.formatln("Calling destructor of A"); } } void main() { GC.disable(); A foo = new A; Thread.sleep(2); A bar = new A; Thread.sleep(2); delete foo; delete bar; }output:
Calling constructor of A Calling constructor of A Calling destructor of A Calling destructor of Athis works as it should.