Prevent crash if compiler errors (or any other log messages) contained '%' (thanks to Boaz for pointing out)
It still crashes: Here is the output form DMD.exe
E:\Home\My Documents\CodeBlocks Projects\D>c:\dmd\bin\dmd.exe main.d stud
ent.d -v -g -debug -unittest -od.objs -ofd.exe
parse main
main.d(22): identifier or integer expected, not )
main.d(23): found '{' when expecting ')'
main.d(26): found '"\x0aName is: %s\x0aAge is: %d"' when expecting ')'
main.d(26): no identifier for declarator writefln
main.d(26): semicolon expected, not '.'
main.d(26): no identifier for declarator .Name
main.d(26): semicolon expected, not '.'
main.d(26): no identifier for declarator .Age
main.d(26): semicolon expected, not ')'
main.d(26): Declaration expected, not ')'
main.d(28): found '"\x0a\x0aNow press a key to continue!"' when expecting ')'
main.d(28): no identifier for declarator printf
main.d(28): semicolon expected, not ')'
main.d(28): Declaration expected, not ')'
main.d(29): no identifier for declarator getch
main.d(30): unrecognized declaration
and here is the code that I try to compile within Code::Blocks
import std.stdio;
void main()
{
char[] ch = "now";
writefln("\ncrash %s %d", ch, 333 );
}
writefln("\ncrash %s %d", ch, 333 );
}
import std.stdio;
void main()
{
char[] ch = "now";
writefln("\ncrash %s ", ch, 333 );
}
writefln("\ncrash %d", ch, 333 );
}
The above doesn't crash Code::Blocks.
It seems it crashes when there are two: %
This does not cause a crash:
import std.stdio;
void main()
{
char[] ch = "now";
writefln("\ncrash %s ", ch, 333 );
}
writefln("\ncrash %d %d", ch, 333 );
}
console output: E:\Home\Hristo\My Documents\CodeBlocks Projects\D Crash>dmd main.d
main.d(11): found '"\x0acrash %d %d"' when expecting ')'
main.d(11): no identifier for declarator writefln
main.d(11): no identifier for declarator writefln
main.d(11): semicolon expected, not '333'
main.d(11): Declaration expected, not '333'
main.d(12): unrecognized declaration
but this does:
import std.stdio;
void main()
{
char[] ch = "now";
writefln("\ncrash %s ", ch, 333 );
}
writefln("\ncrash %s %d", ch, 333 );
}
Note the "%s".
This is the console output when I run the compiler from the command prompt:
main.d(11): found '"\x0acrash %s %d"' when expecting ')'
main.d(11): no identifier for declarator writefln
main.d(11): no identifier for declarator writefln
main.d(11): semicolon expected, not '333'
main.d(11): Declaration expected, not '333'
main.d(12): unrecognized declaration
I don't have D on my system, but I do have GCC.
#include <stdio.h>
#include <stdlib.h>
int main()
{
char ch[] = "now";
printf("crash %s %d", ch, 333);
}
No crash. I'm not sure if it is equivalent or not, but it doesn't crash C::B.....
#include <stdio.h>
#include <stdlib.h>
int main()
{
char ch[] = "now";
printf("crash %s", ch, 333);
}
printf("crash %s %d", ch, 333);
}
This doesn't cause a crash.
And that's from when CB crashes:
Unhandled exception at 0x00000000 in codeblocks.exe: 0xC0000005: Access violation reading location 0x0000000c.
Unhandled exception at 0xb25374ba in codeblocks.exe: 0xC0000005: Access violation reading location 0xb25374ba.