D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5093 - improve error for importing std.c.windows.windows
Summary: improve error for importing std.c.windows.windows
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2010-10-21 09:08 UTC by Jesse Phillips
Modified: 2018-05-18 10:18 UTC (History)
4 users (show)

See Also:


Attachments
PATCH against rev 755: implement a module import backtrace for static assert (4.24 KB, patch)
2010-11-15 11:03 UTC, simon
Details | Diff
PATCH against rev 755: implement a module import backtrace for static assert (4.30 KB, application/octet-stream)
2010-11-16 15:37 UTC, simon
Details
PATCH against rev 755: implement a module import backtrace for static assert (4.45 KB, patch)
2010-11-17 13:03 UTC, simon
Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description Jesse Phillips 2010-10-21 09:08:13 UTC
Currently when you import std.c.windows.windows on a non-Windows machine, the file and line number of std/c/windows/windows.d is returned due to a static assert(0).

This is great and all, but it would be really nice to have the file and line number of the importer. I don't know of how to improve this. Maybe an improvement to DMD so that a module that is imported and has a static assert(0) results in the importer file and line being used?
Comment 1 bearophile_hugs 2010-10-21 09:40:34 UTC
More generally, it may useful to have an error message for failed imports that shows the file name and line number of the module that contains the import statement.
Comment 2 Steven Schveighoffer 2010-10-21 10:43:50 UTC
you might want to try dmd -v.  It shows imports in the order they were imported.  It doesn't show the file which imports it, but you can get a good idea probably from the prior file list.

I'd say adding the file imported from would be a good thing to add to -v.
Comment 3 simon 2010-11-15 11:03:49 UTC
Created attachment 812 [details]
PATCH against rev 755: implement a module import backtrace for static assert

Implements a module import back-trace for static asserts.

This ought to be implemented for non-static asserts as well,
but that probably involves mucking about in the back end
and I can't be bothered diving into that at the mo.
Comment 4 simon 2010-11-16 15:37:40 UTC
Created attachment 816 [details]
PATCH against rev 755: implement a module import backtrace for static assert

modified patch so it doesn't print module back trace when inside a template,
the template instantiation trace already gets printed.
Comment 5 simon 2010-11-17 13:03:19 UTC
Created attachment 818 [details]
PATCH against rev 755: implement a module import backtrace for static assert

...and printing the correct import location might help
Comment 6 Dmitry Olshansky 2018-05-18 10:18:49 UTC
This program compiles fine on Ubuntu right now:

---

import std.c.windows.windows;

---

Was fixed years ago when we introduced top-level version per platform in each file.