pragma(__ctfe)

Steven Schveighoffer schveiguy at gmail.com
Thu Sep 28 17:08:02 UTC 2023


On 9/28/23 4:02 AM, Richard (Rikki) Andrew Cattermole wrote:
> On 28/09/2023 8:36 PM, Nicholas Wilson wrote:
>> It will screw up .di generation, and make separate compilation more 
>> difficult.
> 
> No not really, think about the constraints of CTFE.
> 
> You can't elide a function body which is to be used from CTFE. Since you 
> have to have the function body to CTFE it.
> 
> So where the annotation exists, doesn't matter too much.

I think what Nic means is if you have a function:

```d
string genMixin(string param) {
    assert(__ctfe);
    return "int " ~ param ~ " = 5;";
}
```

Now, if that doesn't go into the binary, what happens with the di 
generated file?

```d
string genMixin(string param);
```

oops, there's the function, but it can't be called for CTFE, *and* it 
doesn't exist in the object file.

Personally, I don't see the problem here. Don't use .di files generation 
for d files that contain those functions.

Or the compiler can detect it, and omit the function, but meh.

-Steve


More information about the Digitalmars-d mailing list