Would appreciate some help porting Q3VM to D (mainly C macros and type conversions)
matheus
matheus at gmail.com
Fri Oct 18 19:43:03 UTC 2024
On Friday, 18 October 2024 at 14:41:15 UTC, Mark Bauermeister
wrote:
> ...No more segfaults thus far but strangely the proper switch
> case...
One thing that I can think looking at your code:
import std.stdio;
void main(){
int op = 1;
switch(op){
default: writeln("default"); return;
version(XYZ){
case 1: writeln(op); break;
}
case 2: writeln(op);
}
}
Since XYZ is never set, case 1 will never hit and it will print
"default". if you comment or take "version(XYZ)" out there it
will work.
Code:
https://run.dlang.io/?compiler=dmd&args=-unittest&source=void+main%28%29%0A%7B%0A++++import+std.stdio+%3A+writefln%3B%0A++++import+std.algorithm.sorting+%3A+sort%3B%0A++++import+std.range+%3A+chain%3B%0A%0A++++int%5B%5D+arr1+%3D+%5B4%2C+9%2C+7%5D%3B%0A++++int%5B%5D+arr2+%3D+%5B5%2C+2%2C+1%2C+10%5D%3B%0A++++int%5B%5D+arr3+%3D+%5B6%2C+8%2C+3%5D%3B%0A++++%2F%2F+%40nogc+functions+are+guaranteed+by+the+compiler%0A++++%2F%2F+to+be+without+any+GC+allocation%0A++++%28%29+%40nogc+%7B%0A++++++++sort%28chain%28arr1%2C+arr2%2C+arr3%29%29%3B%0A++++%7D%28%29%3B%0A++++writefln%28%22%25s%5Cn%25s%5Cn%25s%5Cn%22%2C+arr1%2C+arr2%2C+arr3%29%3B%0A%7D%0A%0A
Matheus.
More information about the Digitalmars-d-learn
mailing list