digitalmars.D.bugs - std/c/time.d const sysconf bug?
- Dawid =?UTF-8?B?Q2nEmcW8YXJraWV3aWN6?= (14/14) Jan 07 2007 $ dmd
- Thomas Kuehne (25/39) Jan 07 2007 -----BEGIN PGP SIGNED MESSAGE-----
- Frits van Bommel (4/30) Jan 07 2007 My first instinct when I read that message was to post just such a
- Dawid =?UTF-8?B?Q2nEmcW8YXJraWV3aWN6?= (2/11) Jan 08 2007 Yes indeed. This is D.bug, not D.learn, right? :)
$ dmd Digital Mars D Compiler v1 ... $ make + /home/dpc/stg/d/bin/dsss_build -I/home/dpc/stg/d/include/d -LIBPATH=/home/dpc/stg/d/lib/ -LIBPATH=./ -od. server.d -Tserver /home/dpc/stg/d/include/d/std/c/time.d(40): Error: non-constant expression (sysconf)(2) else version (linux) { extern (C) int sysconf(int); const clock_t CLK_TCK = cast(clock_t) sysconf(2); // <---------- THIS } How can THIS be a const, hmm?
Jan 07 2007
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dawid Ci??arkiewicz schrieb am 2007-01-07:$ dmd Digital Mars D Compiler v1 ... $ make + /home/dpc/stg/d/bin/dsss_build -I/home/dpc/stg/d/include/d -LIBPATH=/home/dpc/stg/d/lib/ -LIBPATH=./ -od. server.d -Tserver /home/dpc/stg/d/include/d/std/c/time.d(40): Error: non-constant expression (sysconf)(2) else version (linux) { extern (C) int sysconf(int); const clock_t CLK_TCK = cast(clock_t) sysconf(2); // <---------- THIS }Please replace the line with: clock_t CLK_TCK(){ return cast(clock_t) sysconf(2); } Using "static this" would work for common use-cases but not if running applications are beeing migrated between different systems.How can THIS be a const, hmm?D's const isn't exactly Java's const ... http://www.digitalmars.com/d/attribute.html#const sounds good, but Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFoTJrLK5blCcjpWoRAst2AJ9dHVqnmfr9SJ50Dn33jaum0+kdWwCgpwtQ mt5d7tOj6i/8dveIX77ZAo8= =7oOu -----END PGP SIGNATURE-----
Jan 07 2007
Thomas Kuehne wrote:-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dawid Ci??arkiewicz schrieb am 2007-01-07:My first instinct when I read that message was to post just such a reply, but then I noticed he wasn't talking about his own code. This is in Phobos's std.c.time module...$ dmd Digital Mars D Compiler v1 ... $ make + /home/dpc/stg/d/bin/dsss_build -I/home/dpc/stg/d/include/d -LIBPATH=/home/dpc/stg/d/lib/ -LIBPATH=./ -od. server.d -Tserver /home/dpc/stg/d/include/d/std/c/time.d(40): Error: non-constant expression (sysconf)(2) else version (linux) { extern (C) int sysconf(int); const clock_t CLK_TCK = cast(clock_t) sysconf(2); // <---------- THIS }Please replace the line with: clock_t CLK_TCK(){ return cast(clock_t) sysconf(2); } Using "static this" would work for common use-cases but not if running applications are beeing migrated between different systems.
Jan 07 2007
Frits van Bommel wrote:Yes indeed. This is D.bug, not D.learn, right? :)Please replace the line with: clock_t CLK_TCK(){ return cast(clock_t) sysconf(2); } Using "static this" would work for common use-cases but not if running applications are beeing migrated between different systems.My first instinct when I read that message was to post just such a reply, but then I noticed he wasn't talking about his own code. This is in Phobos's std.c.time module...
Jan 08 2007