digitalmars.D.learn - Issuing compile-time warnings with line numbers?
- Andrej Mitrovic (18/18) Sep 20 2011 Won't compile for obvious reasons:
- Jacob Carlborg (5/23) Sep 20 2011 Have a look at: http://d-programming-language.org/templates-revisited.ht...
- Andrej Mitrovic (5/6) Sep 21 2011 Right, but as I've said conv.to works at compile-time so that's
- Jacob Carlborg (4/10) Sep 21 2011 Oh, I missed one of your posts, sorry.
Won't compile for obvious reasons: struct Bar { } struct Foo { this(Bar bar, int line = __LINE__) { pragma(msg, "Warning: Constructing Foo with Bar incurs precision loss. Line: " ~ line); } } void main() { auto foo = Foo(Bar()); } That's just an example, but I want to issue a compile-time warning when a specific ctor is called because it might incur precision loss. I want to give the user the line number of the call, but I can't call to!string since it's not ctfe-able, so do I have any other options?
Sep 20 2011
On 2011-09-21 02:18, Andrej Mitrovic wrote:Won't compile for obvious reasons: struct Bar { } struct Foo { this(Bar bar, int line = __LINE__) { pragma(msg, "Warning: Constructing Foo with Bar incurs precision loss. Line: " ~ line); } } void main() { auto foo = Foo(Bar()); } That's just an example, but I want to issue a compile-time warning when a specific ctor is called because it might incur precision loss. I want to give the user the line number of the call, but I can't call to!string since it's not ctfe-able, so do I have any other options?Have a look at: http://d-programming-language.org/templates-revisited.html Search for "Template Metaprogramming With Strings". -- /Jacob Carlborg
Sep 20 2011
On 9/21/11, Jacob Carlborg <doob me.com> wrote:Have a look at: http://d-programming-language.org/templates-revisited.htmlRight, but as I've said conv.to works at compile-time so that's unnecessary. Maybe adding a note there about this would be nice, so people don't spend time reimplementing common compile-time conversions that conv.to can already do.
Sep 21 2011
On 2011-09-21 13:59, Andrej Mitrovic wrote:On 9/21/11, Jacob Carlborg<doob me.com> wrote:Oh, I missed one of your posts, sorry. -- /Jacob CarlborgHave a look at: http://d-programming-language.org/templates-revisited.htmlRight, but as I've said conv.to works at compile-time so that's unnecessary. Maybe adding a note there about this would be nice, so people don't spend time reimplementing common compile-time conversions that conv.to can already do.
Sep 21 2011