Use & when passing function references to HashTable constructor#1728
Use & when passing function references to HashTable constructor#1728valpackett wants to merge 2 commits intognunn1:masterfrom
Conversation
| HashTable createHashTable() { | ||
| import gtkc.glib; | ||
| return new HashTable(g_str_hash, g_str_equal); | ||
| return new HashTable(&g_str_hash, &g_str_equal); |
There was a problem hiding this comment.
There was a problem hiding this comment.
ref is a keyword in function signatures, not in calls??
There was a problem hiding this comment.
Yes, if you need this then do it in the function call. I assume this error will propagate to other calls, right? Or is it context specific? If then then this is fine.
There was a problem hiding this comment.
HashTable is obviously not a Tilix type, the constructor we're calling here is GtkD's wrapper around g_hash_table_new, we're giving it pointers to C functions (which g_str_hash and _equal are)
There was a problem hiding this comment.
So it seems this is the correct approach, I wish GtkD would provide more type safety.
ldc 1.16.0 complains about trying to call `g_str_hash` / `g_str_equal` with no arguments
/usr/local/include/d/object.d(3219,36): Error: cannot implicitly convert expression aa of type shared(ProcessStatus[int]) to const(shared(ProcessStatus)[int]) ../source/gx/tilix/terminal/monitor.d(46,46): Error: template instance object.values!(shared(ProcessStatus[int]), shared(ProcessStatus), int) error instantiating
|
Added patch for another problem with newer ldc (1.18.0): |
b53c46c to
2f9d050
Compare
|
From what it looks like, LDC builds Tilix just fine today, so I think GtkD added the necessary ref's to make this work. |
ldc 1.16.0 complains about trying to call
g_str_hash/g_str_equalwith no arguments