importC reflection drop const attribute bugs

Dakota dakota at gmail.com
Tue Feb 27 12:23:40 UTC 2024


for this test case:

test2i.c
```c
typedef struct Message Message;
int tryEncode(const Message* msg);
```


test2d.d
```d
import test2i;

extern(C) int main(int argc, char** argv){
	doTest!test2i();
	return 0;
}

void doTest(alias M)(){
	static foreach(symbol; __traits(allMembers, M)) if( true ) {
		static if( __traits(compiles, typeof(__traits(getMember, M, 
symbol))) ) {
			alias T = typeof(__traits(getMember, M, symbol));
			static if( is( T == function) ) {
				pragma(msg, symbol, "\t", T);
			}
		}
	}
}

```

```sh
dmd  --version
DMD64 D Compiler v2.107.1-rc.1
Copyright (C) 1999-2024 by The D Language Foundation, All Rights 
Reserved written by Walter Bright

dmd test2d.d -betterC

tryEncode	extern (C) int(Message* msg)
```

the output should be `tryEncode	extern (C) int(const(Message)* 
msg)`

=============

there is one more bugs: if I pass T as alias to template, I will 
loss parameters name. (ParameterIdentifierTuple return empty 
string)



More information about the Digitalmars-d mailing list