Re: ImportC issue?

2023-04-19 Thread DLearner via Digitalmars-d-learn

On Wednesday, 19 April 2023 at 14:42:44 UTC, bachmeier wrote:
[...]
My understanding (from my occasional use of Windows) is that 
DMD installs the Community Edition of Visual Studio. That 
should solve your original issue, and you shouldn't need to 
mess with sppn.exe.


Well it took a little while, but I can confirm that if you have a 
D function like:


```
extern(C) void DCallee() {
   import core.stdc.stdio : printf;

   printf("Entered DCallee.\n");


   printf("Exiting DCallee.\n");
}
```

called from a C function like:

```
//  C Master calling D (under -betterC restrictions).

#include 

extern void DCallee();

int main()
{
   printf("MastC Entered.\n");

   DCallee();

   printf("MastC Exiting.\n");
   return 0;
}
```

Where the compilation is run from the batch file:

```
Rem Compile, link and run batch file.
IF EXIST .\DCallee.exe del .\DCallee.exe
IF EXIST .\DCallee.map del .\DCallee.map
IF EXIST .\DCallee.obj del .\DCallee.obj

IF EXIST .\MastC.exe del .\MastC.exe
IF EXIST .\MastC.map del .\MastC.map
IF EXIST .\MastC.obj del .\MastC.obj

dmd -m32omf -betterC -c DCallee.d

dmc MastC.c DCallee.obj
MastC.exe
Rem Exited compile, link and run batch file.
```

Then everything runs properly.

As an aside, it was a surprise to me to discover that the order 
of the file names in the
dmc line was significant, bearing in mind MastC.c contains a 
'main' function, and DCallee.d does not.


As a further aside, I do recall the installer loading Visual 
Studio, but it didn't seem to help.




Re: ImportC issue?

2023-04-19 Thread bachmeier via Digitalmars-d-learn

On Wednesday, 19 April 2023 at 13:11:45 UTC, DLearner wrote:
On Wednesday, 19 April 2023 at 12:09:44 UTC, Richard (Rikki) 
Andrew Cattermole wrote:

On 20/04/2023 12:07 AM, DLearner wrote:
Error: C preprocess command sppn.exe failed for file ex01.c, 
exit status 1


Did you verify that sppn is accessible in that shell?

As in run it, can it be found?

If not its just a PATH variable issue.


SPPN.exe not visible from that command prompt, but neither 
(using File Explorer) anywhere on the C: drive (lots of 
SPPNP.DLL's, in various Windows locations).


If SPPN.exe essential to a component of DMD, was it not 
downloaded with it (and PATH modified to point to it), by the 
installer?


My understanding (from my occasional use of Windows) is that DMD 
installs the Community Edition of Visual Studio. That should 
solve your original issue, and you shouldn't need to mess with 
sppn.exe.


Re: ImportC issue?

2023-04-19 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn

On 20/04/2023 1:11 AM, DLearner wrote:
If SPPN.exe essential to a component of DMD, was it not downloaded with 
it (and PATH modified to point to it), by the installer?


It is not an essential component of dmd.

It is one option in the usage of an experimental feature inside of dmd 
that is not ready for general use.


Re: ImportC issue?

2023-04-19 Thread DLearner via Digitalmars-d-learn
On Wednesday, 19 April 2023 at 12:09:44 UTC, Richard (Rikki) 
Andrew Cattermole wrote:

On 20/04/2023 12:07 AM, DLearner wrote:
Error: C preprocess command sppn.exe failed for file ex01.c, 
exit status 1


Did you verify that sppn is accessible in that shell?

As in run it, can it be found?

If not its just a PATH variable issue.


SPPN.exe not visible from that command prompt, but neither (using 
File Explorer) anywhere on the C: drive (lots of SPPNP.DLL's, in 
various Windows locations).


If SPPN.exe essential to a component of DMD, was it not 
downloaded with it (and PATH modified to point to it), by the 
installer?


Re: ImportC issue?

2023-04-19 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn

On 20/04/2023 12:07 AM, DLearner wrote:

Error: C preprocess command sppn.exe failed for file ex01.c, exit status 1


Did you verify that sppn is accessible in that shell?

As in run it, can it be found?

If not its just a PATH variable issue.


Re: ImportC issue?

2023-04-19 Thread DLearner via Digitalmars-d-learn

On Wednesday, 19 April 2023 at 11:50:28 UTC, bachmeier wrote:
[...]

Did you use the switch `-m32omf`?

https://dlang.org/spec/importc.html#auto-cpp


No so following the references I tried every preprocessor option 
I could find:


```
C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c -m32omf
failed launching sppn.exe ex01.c 
-HIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h 
-ED -oex01.i


Error: C preprocess command sppn.exe failed for file ex01.c, exit 
status 1



C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c -c -m32omf
failed launching sppn.exe ex01.c 
-HIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h 
-ED -oex01.i


Error: C preprocess command sppn.exe failed for file ex01.c, exit 
status 1



C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c -c -m32mscoff
failed launching cl.exe /P /Zc:preprocessor /PD /nologo ex01.c 
/FIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h 
/Fiex01.i
Error: C preprocess command cl.exe failed for file ex01.c, exit 
status 1



C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c -c -m64
failed launching cl.exe /P /Zc:preprocessor /PD /nologo ex01.c 
/FIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h 
/Fiex01.i
Error: C preprocess command cl.exe failed for file ex01.c, exit 
status 1

```
Unfortunately all options failed.


Re: ImportC issue?

2023-04-19 Thread bachmeier via Digitalmars-d-learn

On Wednesday, 19 April 2023 at 10:21:22 UTC, DLearner wrote:

C source ex01.c:
```
#include 
int main()
{
   printf("hello world\n");
   return 0;
}
```
'dmc ex01.c' produces message:
```
link ex01,,,user32+kernel32/noi;
```

but does generate .obj, .map and .exe files,
and the exe executes properly.

However, trying to use ImportC via 'dmd ex01.c' produces 
messages:

```
failed launching cl.exe /P /Zc:preprocessor /PD /nologo ex01.c 
/FIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h 
/Fiex01.i
Error: C preprocess command cl.exe failed for file ex01.c, exit 
status 1

```

This behaviour was repeated after a complete fresh 
re-installation of dmd & dmc from the website.


Did you use the switch `-m32omf`?

https://dlang.org/spec/importc.html#auto-cpp


Re: serve-d and emacs

2023-04-19 Thread Per Nordlöw via Digitalmars-d-learn

On Wednesday, 19 April 2023 at 10:35:31 UTC, Per Nordlöw wrote:

On Wednesday, 19 April 2023 at 09:39:19 UTC, Per Nordlöw wrote:

On Wednesday, 19 April 2023 at 09:37:56 UTC, Per Nordlöw wrote:

. Has anybody gotten these things to work?


I'm gonna try `lsp-mode` instead of `eglot`.


I believe this should work

```elisp
(defun serve-d-command ()
  "Shell command to start serve-d."
  '("dub" "run" "--vquiet" "serve-d"))

(when (require 'lsp nil t)
  (dolist (mode '(d-mode d-ts-mode))
(add-hook mode #'lsp)
(add-to-list 'lsp-language-id-configuration `(,mode . "d")))
  (lsp-register-client
   (make-lsp-client
:new-connection (lsp-stdio-connection #'serve-d-command)
:major-modes '(d-mode d-ts-mode)
:server-id 'serve-d)))
```

but unfortunately I get status disconncted in the mode-line and 
the call to dub run shuts down. Clues anyone?


Hmm, it turns out that using this a call to lsp-mode with this 
never triggers a call to the elisp function `serve-d-command`


. I don't see what's wrong.


Re: serve-d and emacs

2023-04-19 Thread Per Nordlöw via Digitalmars-d-learn

On Wednesday, 19 April 2023 at 10:35:31 UTC, Per Nordlöw wrote:

I believe this should work

```elisp
(defun serve-d-command ()
  "Shell command to start serve-d."
  '("dub" "run" "--vquiet" "serve-d"))

(when (require 'lsp nil t)
  (dolist (mode '(d-mode d-ts-mode))
(add-hook mode #'lsp)
(add-to-list 'lsp-language-id-configuration `(,mode . "d")))
  (lsp-register-client
   (make-lsp-client
:new-connection (lsp-stdio-connection #'serve-d-command)
:major-modes '(d-mode d-ts-mode)
:server-id 'serve-d)))
```

but unfortunately I get status disconncted in the mode-line and 
the call to dub run shuts down. Clues anyone?


How do I most easily get the debug output from

```
'("dub" "run" "--vquiet" "serve-d")
```

?


Re: serve-d and emacs

2023-04-19 Thread Per Nordlöw via Digitalmars-d-learn

On Wednesday, 19 April 2023 at 09:39:19 UTC, Per Nordlöw wrote:

On Wednesday, 19 April 2023 at 09:37:56 UTC, Per Nordlöw wrote:

. Has anybody gotten these things to work?


I'm gonna try `lsp-mode` instead of `eglot`.


I believe this should work

```elisp
(defun serve-d-command ()
  "Shell command to start serve-d."
  '("dub" "run" "--vquiet" "serve-d"))

(when (require 'lsp nil t)
  (dolist (mode '(d-mode d-ts-mode))
(add-hook mode #'lsp)
(add-to-list 'lsp-language-id-configuration `(,mode . "d")))
  (lsp-register-client
   (make-lsp-client
:new-connection (lsp-stdio-connection #'serve-d-command)
:major-modes '(d-mode d-ts-mode)
:server-id 'serve-d)))
```

but unfortunately I get status disconncted in the mode-line and 
the call to dub run shuts down. Clues anyone?


Re: ImportC issue?

2023-04-19 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn

Yeah cl is the MSVC compiler being used for preprocessing.

So for whatever reason its not using dmc, hence the error.


ImportC issue?

2023-04-19 Thread DLearner via Digitalmars-d-learn

C source ex01.c:
```
#include 
int main()
{
   printf("hello world\n");
   return 0;
}
```
'dmc ex01.c' produces message:
```
link ex01,,,user32+kernel32/noi;
```

but does generate .obj, .map and .exe files,
and the exe executes properly.

However, trying to use ImportC via 'dmd ex01.c' produces messages:
```
failed launching cl.exe /P /Zc:preprocessor /PD /nologo ex01.c 
/FIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h 
/Fiex01.i
Error: C preprocess command cl.exe failed for file ex01.c, exit 
status 1

```

This behaviour was repeated after a complete fresh 
re-installation of dmd & dmc from the website.


Re: serve-d and emacs

2023-04-19 Thread Per Nordlöw via Digitalmars-d-learn

On Wednesday, 19 April 2023 at 09:37:56 UTC, Per Nordlöw wrote:

. Has anybody gotten these things to work?


I'm gonna try `lsp-mode` instead of `eglot`.


Re: serve-d and emacs

2023-04-19 Thread Per Nordlöw via Digitalmars-d-learn
On Wednesday, 28 April 2021 at 23:04:27 UTC, Christian Köstlin 
wrote:
if you configure it yourself, feel free to share the 
configuration and maybe PR it to serve-d repo.
Its a little tricky, because the basic setup works e.g. with 
emacs 27.2 or newer, but not with 27.1.
All that is needed (if you have the right emacs version and use 
straight for installing packages) is:


I'm having problems with serve-d + eglot in Emacs. All calls to

```
eglot-find-declaration
eglot-find-implementation
eglot-find-typeDefinition
```

answers as

```
eglot--error: [eglot] Sorry, this server doesn't do 
:textDocument/declaration

```

Are neither of

```
:textDocument/declaration
```

supported? If so what lsp request type should I use to 
lookup/navigate to definitions? Without such functionality I see 
no use of eglot.


. I'm currently using

```elisp
(use-package eglot
  ;; :straight t
  :ensure t
  :defer t
  :hook (d-mode . eglot-ensure)
  :config
  (progn
;; (add-hook 'd-mode-hook 'eglot-ensure)
(let ((cmd '("dub" "run" "--vquiet" "serve-d")))
  (add-to-list 'eglot-server-programs 
;https://forum.dlang.org/post/s6cpls$pg3$1...@digitalmars.com

   `(d-mode . ,cmd))
	  (add-to-list 'eglot-server-programs 
;https://forum.dlang.org/post/s6cpls$pg3$1...@digitalmars.com

   `(d-ts-mode . ,cmd
  ;; (remove-hook 'd-mode-hook 'eglot-ensure)
  )
```

. Has anybody gotten these things to work?