Re: Is it possible to set/override the name of the source file when piping it into DMD via stdin?

2023-12-13 Thread Siarhei Siamashka via Digitalmars-d-learn
On Wednesday, 13 December 2023 at 19:51:11 UTC, Adam D Ruppe wrote: On Wednesday, 13 December 2023 at 19:37:09 UTC, Siarhei Siamashka wrote: Now I'm curious. Is it possible to somehow communicate the real source file name to `dmd`, so that it shows up in the error log instead of "__stdin.d"?

Re: Is it possible to set/override the name of the source file when piping it into DMD via stdin?

2023-12-13 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Dec 13, 2023 at 11:58:42AM -0800, H. S. Teoh via Digitalmars-d-learn wrote: [...] > Add a module declaration to your source file. For example: > > echo 'module abc; import std; void main(){writefln(__MODULE__);}' | dmd > -run - > > Output: > abc > > `__stdin` is used as a

Re: Is it possible to set/override the name of the source file when piping it into DMD via stdin?

2023-12-13 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Dec 13, 2023 at 07:37:09PM +, Siarhei Siamashka via Digitalmars-d-learn wrote: > Example: > > ```D > import std; > void main() { > deliberate syntax error here > } > ``` > > ```bash > $ cat example.d | dmd -run - > __stdin.d(3): Error: found `error` when expecting `;` or `=`, did

Re: Is it possible to set/override the name of the source file when piping it into DMD via stdin?

2023-12-13 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 13 December 2023 at 19:37:09 UTC, Siarhei Siamashka wrote: Now I'm curious. Is it possible to somehow communicate the real source file name to `dmd`, so that it shows up in the error log instead of "__stdin.d"? the sequence `#line "filename.d" 1` at the top of the thing might

Is it possible to set/override the name of the source file when piping it into DMD via stdin?

2023-12-13 Thread Siarhei Siamashka via Digitalmars-d-learn
Example: ```D import std; void main() { deliberate syntax error here } ``` ```bash $ cat example.d | dmd -run - __stdin.d(3): Error: found `error` when expecting `;` or `=`, did you mean `deliberate syntax = here`? __stdin.d(3): Error: found `}` when expecting `;` or `=`, did you mean