ImportC now supports function-like macros

Dakota dakota at gmail.com
Fri Mar 1 13:50:32 UTC 2024


On Friday, 1 March 2024 at 11:16:56 UTC, ryuukk_ wrote:
>> I suggestion add a dmd flags to change the behavior, like 
>> --importC-const-pointer=. so the user can choice what kind 
>> behavior they want.
>>
>> some project use transitive const in C, so they can work with 
>> this new options.
>>
>> One more options is translate it into a user-defined template, 
>> this is more flexible. user can return diff result base on the 
>> name. for example:
>>
>> ```c
>> typedef struct Message Message;
>> int tryEncode(const Message* msg);
>> ```
>> =>
>>
>> ```sh
>> struct Message;
>> int tryEncode(importConstPointer!(Message)* msg);
>> ```
>
> Unnecessary template
>
> Perhaps it should be marked `inout`?


In some case `inout` make sense, in other case it should be const 
and not allow accept non-const. so I think a options for dmd or 
template will let user do the choice.



More information about the Digitalmars-d mailing list