Thread overview
Would appreciate some help porting Q3VM to D (mainly C macros and type conversions)
21 hours ago
Mark Bauermeister
20 hours ago
barbosso
19 hours ago
Mark Bauermeister
16 hours ago
Lance Bachmeier
15 hours ago
Mark Bauermeister
15 hours ago
drug007
21 hours ago

For the past 2 days I've been trying to port the Q3VM (https://github.com/jnz/q3vm) to D.
While most of the code is converted, it's somewhat riddled with cast statements and I'm still having trouble getting it to compile without errors.

My conversion can be found here:

https://gist.github.com/markusbkk/442a571353a48c5377c503e7d02570fb

My main problem are the macro functions at line 398 in my code, as well as the compiler telling me that "static variable codeImage cannot be read at compile time".

Would really appreciate some help with this from the D Lords of this group.

20 hours ago

Are you heard of https://github.com/dkorpel/ctod ?

19 hours ago

On Tuesday, 15 October 2024 at 12:27:42 UTC, barbosso wrote:

>

Are you heard of https://github.com/dkorpel/ctod ?

I actually used CTOD for part of the translation but it wouldn't translate the macros correctly. It turned them into weird string mixins.

16 hours ago

On Tuesday, 15 October 2024 at 13:30:03 UTC, Mark Bauermeister wrote:

>

On Tuesday, 15 October 2024 at 12:27:42 UTC, barbosso wrote:

>

Are you heard of https://github.com/dkorpel/ctod ?

I actually used CTOD for part of the translation but it wouldn't translate the macros correctly. It turned them into weird string mixins.

It's not as well known, but ImportC also converts C code to D: https://dlang.org/spec/importc.html#ctod It needs the -inline switch to output function bodies. The last time I used it, there were problems with generation of duplicate items, but it was able to handle most anything I threw at it. Would be worth a try.

15 hours ago

On Tuesday, 15 October 2024 at 16:05:48 UTC, Lance Bachmeier wrote:

>

On Tuesday, 15 October 2024 at 13:30:03 UTC, Mark Bauermeister wrote:

>

On Tuesday, 15 October 2024 at 12:27:42 UTC, barbosso wrote:

>

Are you heard of https://github.com/dkorpel/ctod ?

I actually used CTOD for part of the translation but it wouldn't translate the macros correctly. It turned them into weird string mixins.

It's not as well known, but ImportC also converts C code to D: https://dlang.org/spec/importc.html#ctod It needs the -inline switch to output function bodies. The last time I used it, there were problems with generation of duplicate items, but it was able to handle most anything I threw at it. Would be worth a try.

Thanks! That helped me figure out some more macros.

Now if only I could figure out how to resolve "variable codeImage cannot be read at compile time". That's the last thing neither of those automation solutions can help me with.

15 hours ago
On 15.10.2024 20:37, Mark Bauermeister wrote:
> On Tuesday, 15 October 2024 at 16:05:48 UTC, Lance Bachmeier wrote:
>> On Tuesday, 15 October 2024 at 13:30:03 UTC, Mark Bauermeister wrote:
>>> On Tuesday, 15 October 2024 at 12:27:42 UTC, barbosso wrote:
>>>> Are you heard of https://github.com/dkorpel/ctod ?
>>>
>>> I actually used CTOD for part of the translation but it wouldn't translate the macros correctly. It turned them into weird string mixins.
>>
>> It's not as well known, but ImportC also converts C code to D: https://dlang.org/spec/importc.html#ctod It needs the -inline switch to output function bodies. The last time I used it, there were problems with generation of duplicate items, but it was able to handle most anything I threw at it. Would be worth a try.
> 
> Thanks! That helped me figure out some more macros.
> 
> Now if only I could figure out how to resolve "variable `codeImage` cannot be read at compile time". That's the last thing neither of those automation solutions can help me with.

if you mean line 966 you need to replace `enum` by `const` or even `auto`. `enum` means the value should be available in compile time.