www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - dmd debug(level) Is it obsolete?

reply Brother Bill <brotherbill mail.com> writes:
Page 462 of book: Programming in D

This won't compile.  Is this obsolete?
```
app.d(8,8): Error: identifier expected inside `debug(...)`, not 
`1`
     debug(1) writeln("entered myFunction");
           ^
source\app.d(10,8): Error: identifier expected inside 
`debug(...)`, not `2`
     debug(2) {
           ^
Error C:\D\dmd2\windows\bin64\dmd.exe failed with exit code 1.
```

source/app.d
```
debug import std.stdio;

void main() {
	myFunction("deneme.txt", [10, 4, 100]);
}

void myFunction(string fileName, int[] values) {
	debug(1) writeln("entered myFunction");

	debug(2) {
		writeln("the arguments:");
		writeln("  file name: ", fileName);
		
		foreach (i, value; values) {
			writefln("  %4s: %s", i, value);
		}
	}

	// ... the implementation of the function ...
}

```
Aug 17
next sibling parent "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
That was removed a while back.

https://github.com/dlang/dmd/pull/20713
Aug 17
prev sibling parent Nick Treleaven <nick geany.org> writes:
On Sunday, 17 August 2025 at 14:59:00 UTC, Brother Bill wrote:
 Page 462 of book: Programming in D

 This won't compile.  Is this obsolete?
 ```
 app.d(8,8): Error: identifier expected inside `debug(...)`, not 
 `1`
     debug(1) writeln("entered myFunction");
           ^
Yes, for rationale see: https://dlang.org/changelog/2.101.0.html#dmd.deprecate_version_int
Aug 17