www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - betterC mode and std.stdio File

reply samrose <samroseahmed gmail.com> writes:
I was writing some D with the -betterC option, which is quite 
nice. I was wondering if it is possible to use std.stdio File 
reading with the -betterC option.

It is working with -debug mode build but I get an error when 
building with release:

```
/usr/local/opt/dmd/include/dlang/dmd/std/exception.d(516,9): 
Error: Cannot use throw statements with -betterC
/usr/local/opt/dmd/include/dlang/dmd/std/exception.d(437,21): 
Error: template instance std.exception.bailOut!(ErrnoException) 
error instantiating
```

which seems to be cause by the stdio code using exceptions which 
doesn't work for betterC.
May 16 2020
parent Paul Backus <snarwin gmail.com> writes:
On Saturday, 16 May 2020 at 23:00:46 UTC, samrose wrote:
 I was writing some D with the -betterC option, which is quite 
 nice. I was wondering if it is possible to use std.stdio File 
 reading with the -betterC option.

 It is working with -debug mode build but I get an error when 
 building with release:

 ```
 /usr/local/opt/dmd/include/dlang/dmd/std/exception.d(516,9): 
 Error: Cannot use throw statements with -betterC
 /usr/local/opt/dmd/include/dlang/dmd/std/exception.d(437,21): 
 Error: template instance std.exception.bailOut!(ErrnoException) 
 error instantiating
 ```

 which seems to be cause by the stdio code using exceptions 
 which doesn't work for betterC.
Unfortunately, D's std.stdio.File is not betterC-compatible. You will have to use core.stdc.stdio instead.
May 16 2020