digitalmars.D.bugs - [Issue 10522] New: __FILE__ and other special keywords cannot be used with printf
- d-bugmail puremagic.com (29/30) Jul 01 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10522
- d-bugmail puremagic.com (16/16) Aug 19 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10522
- d-bugmail puremagic.com (8/11) Aug 19 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10522
http://d.puremagic.com/issues/show_bug.cgi?id=10522 Summary: __FILE__ and other special keywords cannot be used with printf Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: andrej.mitrovich gmail.com 15:00:08 PDT --- ----- import std.stdio; void main() { printf("-- %s\n", __FILE__); printf("-- %s\n", __FUNCTION__); printf("-- %s\n", __PRETTY_FUNCTION__); } -----object.Error: Access ViolationThe use-case are printf statements in destructors, which unlike writef will avoid any allocations (which typically fail in dtors due to the GC being stopped). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 01 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10522 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies gmail.com Resolution| |INVALID Neither can string literals! printf is a c-varargs function, and has no way of knowing you want the implicit conversion to const(char)*. Solutions: printf("-- %s\n", cast(const(char*))__FILE__); printf("-- %.*s\n", __FILE__.length, __FILE__.ptr); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 19 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10522 08:35:40 PDT ---Neither can string literals! printf is a c-varargs function, and has no way of knowing you want the implicit conversion to const(char)*.I guess that shows how spoiled I am by D's variadic templates. :)printf("-- %s\n", cast(const(char*))__FILE__);Also __FILE__.ptr and __FILE__.toStringz. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 19 2013