Re: Problem with ImportC example?

2023-01-18 Thread bachmeier via Digitalmars-d-learn

On Wednesday, 18 January 2023 at 16:51:27 UTC, bachmeier wrote:
On Wednesday, 18 January 2023 at 16:37:17 UTC, Ali Çehreli 
wrote:

On 1/18/23 08:04, DLearner wrote:

> Unfortunately, neither works:
> ```
> C:\Users\SoftDev>cl.exe
> 'cl.exe' is not recognized as an internal or external 
> command,

> operable program or batch file.

That supports the theory that you don't have a C compiler 
installed that dmd can use for preprocessing C files.


Ali


The 
[documentation](https://dlang.org/spec/importc.html#auto-cpp) 
says


When compiling for Windows with the -m32mscoff or the -m64 
switch, cl.exe /P /Zc:preprocessor will be used as the 
preprocessor.


It might be useful for someone to add more information. I would 
certainly have no idea what that means if I tried to use 
Windows.


Or perhaps stated better, I'd have no idea what I'm supposed to 
install or set up to get it to work.


Re: Problem with ImportC example?

2023-01-18 Thread bachmeier via Digitalmars-d-learn

On Wednesday, 18 January 2023 at 16:37:17 UTC, Ali Çehreli wrote:

On 1/18/23 08:04, DLearner wrote:

> Unfortunately, neither works:
> ```
> C:\Users\SoftDev>cl.exe
> 'cl.exe' is not recognized as an internal or external command,
> operable program or batch file.

That supports the theory that you don't have a C compiler 
installed that dmd can use for preprocessing C files.


Ali


The [documentation](https://dlang.org/spec/importc.html#auto-cpp) 
says


When compiling for Windows with the -m32mscoff or the -m64 
switch, cl.exe /P /Zc:preprocessor will be used as the 
preprocessor.


It might be useful for someone to add more information. I would 
certainly have no idea what that means if I tried to use Windows.


Re: Problem with ImportC example?

2023-01-18 Thread Ali Çehreli via Digitalmars-d-learn

On 1/18/23 08:04, DLearner wrote:

> Unfortunately, neither works:
> ```
> C:\Users\SoftDev>cl.exe
> 'cl.exe' is not recognized as an internal or external command,
> operable program or batch file.

That supports the theory that you don't have a C compiler installed that 
dmd can use for preprocessing C files.


Ali



Re: Problem with ImportC example?

2023-01-18 Thread DLearner via Digitalmars-d-learn

On Wednesday, 18 January 2023 at 14:18:58 UTC, Salih Dincer wrote:

On Wednesday, 18 January 2023 at 13:45:04 UTC, DLearner wrote:

On Tuesday, 17 January 2023 at 22:11:46 UTC, Ali Çehreli wrote:
[...]
dmd relies on system compiler programs for its ImportC 
feature. cl.exe seems to be the compiler. I think it is the 
compiler.


Can you run that program from the command line?


Fails with:

```
C:\Users\SoftDev>c1.exe
'c1.exe' is not recognized as an internal or external command,
operable program or batch file.

```


You will run the cl.exe, not the c1.exe
(be written with the letter l)

SDB@79


Unfortunately, neither works:
```
C:\Users\SoftDev>cl.exe
'cl.exe' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\SoftDev>c1.exe
'c1.exe' is not recognized as an internal or external command,
operable program or batch file.
```


Re: Problem with ImportC example?

2023-01-18 Thread Salih Dincer via Digitalmars-d-learn

On Wednesday, 18 January 2023 at 13:45:04 UTC, DLearner wrote:

On Tuesday, 17 January 2023 at 22:11:46 UTC, Ali Çehreli wrote:
[...]
dmd relies on system compiler programs for its ImportC 
feature. cl.exe seems to be the compiler. I think it is the 
compiler.


Can you run that program from the command line?


Fails with:

```
C:\Users\SoftDev>c1.exe
'c1.exe' is not recognized as an internal or external command,
operable program or batch file.

```


You will run the cl.exe, not the c1.exe
(be written with the letter l)

SDB@79


Re: Problem with ImportC example?

2023-01-18 Thread DLearner via Digitalmars-d-learn

On Tuesday, 17 January 2023 at 22:11:46 UTC, Ali Çehreli wrote:
[...]
dmd relies on system compiler programs for its ImportC feature. 
cl.exe seems to be the compiler. I think it is the compiler.


Can you run that program from the command line?


Fails with:

```
C:\Users\SoftDev>c1.exe
'c1.exe' is not recognized as an internal or external command,
operable program or batch file.

```


Re: Problem with ImportC example?

2023-01-17 Thread zjh via Digitalmars-d-learn

On Wednesday, 18 January 2023 at 02:05:34 UTC, zjh wrote:
< ...

`nightly`:
Unresolved external symbol `__va_start`, function `_fwprintf_`.
link error.




Re: Problem with ImportC example?

2023-01-17 Thread zjh via Digitalmars-d-learn

On Tuesday, 17 January 2023 at 11:16:25 UTC, DLearner wrote:

With the latest version of 'dmd101.2',`dmd a.c`, I get:
C:\Windows 
Kits\10\Include\10.0.22000.0\ucrt\corecrt_wstdio.h|1208| Error: 
function `a.__vswprintf_l` redeclaration with different type
C:\Windows 
Kits\10\Include\10.0.22000.0\ucrt\corecrt_wstdio.h|1405| Error: 
function `a.__swprintf_l` redeclaration with different type




Re: Problem with ImportC example?

2023-01-17 Thread Ali Çehreli via Digitalmars-d-learn

On 1/17/23 12:02, DLearner wrote:

 C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c
 failed launching cl.exe /P /Zc:preprocessor [...]

I don't use Windows for development but that error message makes me 
think cl.exe is not found to be executed.


dmd relies on system compiler programs for its ImportC feature. cl.exe 
seems to be the compiler. I think it is the compiler.


Can you run that program from the command line?

Internet makes me think Visual Studio does not install it by default. 
(?) You may have to select C++ (or C?) when installing. (?)


> FWIW, now tried a few standard D programs, work fine.
> Suggesting VS is not the problem?

Standard D programs don't need a C compiler; dmd is the D compiler. It 
needs a C compiler (to preprocess C sources) for ImportC.


Ali



Re: Problem with ImportC example?

2023-01-17 Thread DLearner via Digitalmars-d-learn

On Tuesday, 17 January 2023 at 19:17:31 UTC, DLearner wrote:

On Tuesday, 17 January 2023 at 17:36:41 UTC, ryuukk_ wrote:

On Tuesday, 17 January 2023 at 17:12:49 UTC, DLearner wrote:

On Tuesday, 17 January 2023 at 15:55:40 UTC, bachmeier wrote:

[...]


Downloaded latest dmd for windows from website:
```
C:\Users\SoftDev>dmd --version
DMD32 D Compiler v2.101.2-dirty
Copyright (C) 1999-2022 by The D Language Foundation, All 
Rights Reserved written by Walter Bright

```

But trial still failed:

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


```


It works for me

```
C:\Users\ryuukk\tmp>dmd -run ex01.c
hello world
```

Double check your visual studio installation, something is 
wrong with your install probably


Tried twice - same result.

But VS installation is itself (IMO) not particularly intuitive.
Would it be possible either to cite known working VS 
installation options on DLang website, or produce Windows 
installation script that takes such options automatically?


FWIW, now tried a few standard D programs, work fine.
Suggesting VS is not the problem?



Re: Problem with ImportC example?

2023-01-17 Thread DLearner via Digitalmars-d-learn

On Tuesday, 17 January 2023 at 17:36:41 UTC, ryuukk_ wrote:

On Tuesday, 17 January 2023 at 17:12:49 UTC, DLearner wrote:

On Tuesday, 17 January 2023 at 15:55:40 UTC, bachmeier wrote:

On Tuesday, 17 January 2023 at 13:21:37 UTC, DLearner wrote:

On Tuesday, 17 January 2023 at 11:21:08 UTC, Dennis wrote:

On Tuesday, 17 January 2023 at 11:16:25 UTC, DLearner wrote:

```

C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c
ex01.c(1): Error: C preprocessor directive `#include` is 
not supported

ex01.c(1): Error: no type for declarator before `#`
ex01.c(5): Error: no type for declarator before `return`
ex01.c(6): Error: no type for declarator before `}`
```


What is your `dmd --version`? I suspect you have a version 
where you still have to manually pre-process the .c file, 
instead of a more recent version which invokes the 
pre-processor itself.


```
C:\Users\SoftDev>dmd --version
DMD32 D Compiler v2.100.2-dirty
Copyright (C) 1999-2022 by The D Language Foundation, All 
Rights Reserved written by Walter Bright


```


You may want to use the nightly build if you're working with 
ImportC: https://github.com/dlang/dmd/releases/tag/nightly 
They're doing a lot of work with it.


Downloaded latest dmd for windows from website:
```
C:\Users\SoftDev>dmd --version
DMD32 D Compiler v2.101.2-dirty
Copyright (C) 1999-2022 by The D Language Foundation, All 
Rights Reserved written by Walter Bright

```

But trial still failed:

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


```


It works for me

```
C:\Users\ryuukk\tmp>dmd -run ex01.c
hello world
```

Double check your visual studio installation, something is 
wrong with your install probably


Tried twice - same result.

But VS installation is itself (IMO) not particularly intuitive.
Would it be possible either to cite known working VS installation 
options on DLang website, or produce Windows installation script 
that takes such options automatically?


Re: Problem with ImportC example?

2023-01-17 Thread ryuukk_ via Digitalmars-d-learn

On Tuesday, 17 January 2023 at 17:12:49 UTC, DLearner wrote:

On Tuesday, 17 January 2023 at 15:55:40 UTC, bachmeier wrote:

On Tuesday, 17 January 2023 at 13:21:37 UTC, DLearner wrote:

On Tuesday, 17 January 2023 at 11:21:08 UTC, Dennis wrote:

On Tuesday, 17 January 2023 at 11:16:25 UTC, DLearner wrote:

```

C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c
ex01.c(1): Error: C preprocessor directive `#include` is 
not supported

ex01.c(1): Error: no type for declarator before `#`
ex01.c(5): Error: no type for declarator before `return`
ex01.c(6): Error: no type for declarator before `}`
```


What is your `dmd --version`? I suspect you have a version 
where you still have to manually pre-process the .c file, 
instead of a more recent version which invokes the 
pre-processor itself.


```
C:\Users\SoftDev>dmd --version
DMD32 D Compiler v2.100.2-dirty
Copyright (C) 1999-2022 by The D Language Foundation, All 
Rights Reserved written by Walter Bright


```


You may want to use the nightly build if you're working with 
ImportC: https://github.com/dlang/dmd/releases/tag/nightly 
They're doing a lot of work with it.


Downloaded latest dmd for windows from website:
```
C:\Users\SoftDev>dmd --version
DMD32 D Compiler v2.101.2-dirty
Copyright (C) 1999-2022 by The D Language Foundation, All 
Rights Reserved written by Walter Bright

```

But trial still failed:

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


```


It works for me

```
C:\Users\ryuukk\tmp>dmd -run ex01.c
hello world
```

Double check your visual studio installation, something is wrong 
with your install probably


Re: Problem with ImportC example?

2023-01-17 Thread DLearner via Digitalmars-d-learn

On Tuesday, 17 January 2023 at 15:55:40 UTC, bachmeier wrote:

On Tuesday, 17 January 2023 at 13:21:37 UTC, DLearner wrote:

On Tuesday, 17 January 2023 at 11:21:08 UTC, Dennis wrote:

On Tuesday, 17 January 2023 at 11:16:25 UTC, DLearner wrote:

```

C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c
ex01.c(1): Error: C preprocessor directive `#include` is not 
supported

ex01.c(1): Error: no type for declarator before `#`
ex01.c(5): Error: no type for declarator before `return`
ex01.c(6): Error: no type for declarator before `}`
```


What is your `dmd --version`? I suspect you have a version 
where you still have to manually pre-process the .c file, 
instead of a more recent version which invokes the 
pre-processor itself.


```
C:\Users\SoftDev>dmd --version
DMD32 D Compiler v2.100.2-dirty
Copyright (C) 1999-2022 by The D Language Foundation, All 
Rights Reserved written by Walter Bright


```


You may want to use the nightly build if you're working with 
ImportC: https://github.com/dlang/dmd/releases/tag/nightly 
They're doing a lot of work with it.


Downloaded latest dmd for windows from website:
```
C:\Users\SoftDev>dmd --version
DMD32 D Compiler v2.101.2-dirty
Copyright (C) 1999-2022 by The D Language Foundation, All Rights 
Reserved written by Walter Bright

```

But trial still failed:

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


```



Re: Problem with ImportC example?

2023-01-17 Thread bachmeier via Digitalmars-d-learn

On Tuesday, 17 January 2023 at 13:21:37 UTC, DLearner wrote:

On Tuesday, 17 January 2023 at 11:21:08 UTC, Dennis wrote:

On Tuesday, 17 January 2023 at 11:16:25 UTC, DLearner wrote:

```

C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c
ex01.c(1): Error: C preprocessor directive `#include` is not 
supported

ex01.c(1): Error: no type for declarator before `#`
ex01.c(5): Error: no type for declarator before `return`
ex01.c(6): Error: no type for declarator before `}`
```


What is your `dmd --version`? I suspect you have a version 
where you still have to manually pre-process the .c file, 
instead of a more recent version which invokes the 
pre-processor itself.


```
C:\Users\SoftDev>dmd --version
DMD32 D Compiler v2.100.2-dirty
Copyright (C) 1999-2022 by The D Language Foundation, All 
Rights Reserved written by Walter Bright


```


You may want to use the nightly build if you're working with 
ImportC: https://github.com/dlang/dmd/releases/tag/nightly 
They're doing a lot of work with it.


Re: Problem with ImportC example?

2023-01-17 Thread DLearner via Digitalmars-d-learn

On Tuesday, 17 January 2023 at 11:21:08 UTC, Dennis wrote:

On Tuesday, 17 January 2023 at 11:16:25 UTC, DLearner wrote:

```

C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c
ex01.c(1): Error: C preprocessor directive `#include` is not 
supported

ex01.c(1): Error: no type for declarator before `#`
ex01.c(5): Error: no type for declarator before `return`
ex01.c(6): Error: no type for declarator before `}`
```


What is your `dmd --version`? I suspect you have a version 
where you still have to manually pre-process the .c file, 
instead of a more recent version which invokes the 
pre-processor itself.


```
C:\Users\SoftDev>dmd --version
DMD32 D Compiler v2.100.2-dirty
Copyright (C) 1999-2022 by The D Language Foundation, All Rights 
Reserved written by Walter Bright


```


Re: Problem with ImportC example?

2023-01-17 Thread Dennis via Digitalmars-d-learn

On Tuesday, 17 January 2023 at 11:16:25 UTC, DLearner wrote:

```

C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c
ex01.c(1): Error: C preprocessor directive `#include` is not 
supported

ex01.c(1): Error: no type for declarator before `#`
ex01.c(5): Error: no type for declarator before `return`
ex01.c(6): Error: no type for declarator before `}`
```


What is your `dmd --version`? I suspect you have a version where 
you still have to manually pre-process the .c file, instead of a 
more recent version which invokes the pre-processor itself.


Problem with ImportC example?

2023-01-17 Thread DLearner via Digitalmars-d-learn

This relates to the first example under 41.1 Quick Examples.

Stored as ex01.c, run as shown.


```
#include 
int main()
{
   printf("hello world\n");
   return 0;
}
```

Produced:

```

C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c
ex01.c(1): Error: C preprocessor directive `#include` is not 
supported

ex01.c(1): Error: no type for declarator before `#`
ex01.c(5): Error: no type for declarator before `return`
ex01.c(6): Error: no type for declarator before `}`
```