ImportC now supports function-like macros
Dakota
dakota at gmail.com
Fri Mar 1 09:52:34 UTC 2024
On Thursday, 29 February 2024 at 19:25:05 UTC, Walter Bright
wrote:
> On 2/29/2024 11:22 AM, Walter Bright wrote:
>> On 2/27/2024 9:26 PM, Dakota wrote:
>>> It is not impractical to add so much `cast(Message*)` into D
>>> code.
>>
>> Hmm, interesting approach!
>>
>
> I'm wondering if you could try adding this:
>
> #define const
>
> and see how far that goes!
On Thursday, 29 February 2024 at 19:25:05 UTC, Walter Bright
wrote:
> On 2/29/2024 11:22 AM, Walter Bright wrote:
>> On 2/27/2024 9:26 PM, Dakota wrote:
>>> It is not impractical to add so much `cast(Message*)` into D
>>> code.
>>
>> Hmm, interesting approach!
>>
>
> I'm wondering if you could try adding this:
>
> #define const
>
> and see how far that goes!
This cloud work but I don't want go this way. (loss const prone
to errors in my d code, because there is a lot `property` read
should return const, and the returned const need pass into other
function chain. remove const is not a solution)
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);
```
More information about the Digitalmars-d
mailing list