digitalmars.D.ldc - unresolved external symbol in BetterC
- Marcel (11/11) Dec 08 2019 I've been getting some weird linker errors around main() when I
- Mike Parker (3/14) Dec 08 2019 Struct destructors should work in betterC. It would be helpful if
- Marcel (14/16) Dec 08 2019 extern(C) void main()
- Marcel (3/12) Dec 08 2019 Ok, I found a way to make this work by writing "nothrow:" inside
- kinke (7/9) Dec 08 2019 Yes, a cleanup/finally is used, apparently in an opAssign. -
- Marcel (2/11) Dec 08 2019 Perfect! Thank you very much!
I've been getting some weird linker errors around main() when I declare a struct with a destructor. Is it possible that exception code is being generated even though I have the -betterC flag enabled? //Example code: extern(C) void main() { auto window = Window("Hello", 0, 0, 800, 600); while(window.IsLive) window.Update; }
Dec 08 2019
On Sunday, 8 December 2019 at 19:29:23 UTC, Marcel wrote:I've been getting some weird linker errors around main() when I declare a struct with a destructor. Is it possible that exception code is being generated even though I have the -betterC flag enabled? //Example code: extern(C) void main() { auto window = Window("Hello", 0, 0, 800, 600); while(window.IsLive) window.Update; }Struct destructors should work in betterC. It would be helpful if you can paste the errors.
Dec 08 2019
On Sunday, 8 December 2019 at 19:36:40 UTC, Mike Parker wrote:Struct destructors should work in betterC. It would be helpful if you can paste the errors.extern(C) void main() { auto pool = ObjectPool!(int)(100); auto a = pool.Acquire; pool.Release(*a); } This code generates the two following errors: 1>Test.obj : error LNK2019: unresolved external symbol _d_enter_cleanup referenced in function "?dtor$5 ?0?"ref Collections.Arrays.Array!(Collections.ObjectPools.ObjectPool!(int, Memory.Allocators.DefaultAllocator).ObjectPool.Entry, Memory.Allocators.DefaultAllocator).Array Collections.Arrays.Array!(Collections.ObjectPools.ObjectPool!(int, Memory.Allocators.DefaultAllocator).ObjectPool.Entry, Memory.Allocators.DefaultAllocator).Array.opAssign(const(Collections.Arrays.Array!(Collections.ObjectPo ls.ObjectPool!(int, Memory.Allocators.DefaultAllocator).ObjectPool.Entry, Memory.Allocators.DefaultAllocator).Array))" (_D11Collections6Arrays__T5ArrayTSQBf11ObjectPools__T10ObjectPoolTiTS6Memory10Allocators16DefaultAllocatorZQCc5EntryTQBxZQDr8opAssignMFNcxSQFgQEw__TQEsTQEpTQDkZQFeZSQGgQFw__TQ sTQFpTQEkZQGe) 4HA" (?dtor$5 ?0?"ref Collections.Arrays.Array!(Collections.ObjectPools.ObjectPool!(int, Memory.Allocators.DefaultAllocator).ObjectPool.Entry, Memory.Allocators.DefaultAllocator).Array Collections.Arrays.Array!(Collections.ObjectPools.ObjectPool!(int, Memory.Allocators.DefaultAllocator).ObjectPool.Entry, Memory.Allocators.DefaultAllocator).Array.opAssign(const(Collections.Arrays.Array!(Collections.ObjectPo ls.ObjectPool!(int, Memory.Allocators.DefaultAllocator).ObjectPool.Entry, Memory.Allocators.DefaultAllocator).Array))" (_D11Collections6Arrays__T5ArrayTSQBf11ObjectPools__T10ObjectPoolTiTS6Memory10Allocators16DefaultAllocatorZQCc5EntryTQBxZQDr8opAssignMFNcxSQFgQEw__TQEsTQEpTQDkZQFeZSQGgQFw__TQFsTQFpTQEkZQGe) 4HA) 1>Test.obj : error LNK2019: unresolved external symbol _d_leave_cleanup referenced in function "?dtor$5 ?0?"ref Collections.Arrays.Array!(Collections.ObjectPools.ObjectPool!(int, Memory.Allocators.DefaultAllocator).ObjectPool.Entry, Memory.Allocators.DefaultAllocator).Array Collections.Arrays.Array!(Collections.ObjectPools.ObjectPool!(int, Memory.Allocators.DefaultAllocator).ObjectPool.Entry, Memory.Allocators.DefaultAllocator).Array.opAssign(const(Collections.Arrays.Array!(Collections.ObjectPo ls.ObjectPool!(int, Memory.Allocators.DefaultAllocator).ObjectPool.Entry, Memory.Allocators.DefaultAllocator).Array))" (_D11Collections6Arrays__T5ArrayTSQBf11ObjectPools__T10ObjectPoolTiTS6Memory10Allocators16DefaultAllocatorZQCc5EntryTQBxZQDr8opAssignMFNcxSQFgQEw__TQEsTQEpTQDkZQFeZSQGgQFw__TQ sTQFpTQEkZQGe) 4HA" (?dtor$5 ?0?"ref Collections.Arrays.Array!(Collections.ObjectPools.ObjectPool!(int, Memory.Allocators.DefaultAllocator).ObjectPool.Entry, Memory.Allocators.DefaultAllocator).Array Collections.Arrays.Array!(Collections.ObjectPools.ObjectPool!(int, Memory.Allocators.DefaultAllocator).ObjectPool.Entry, Memory.Allocators.DefaultAllocator).Array.opAssign(const(Collections.Arrays.Array!(Collections.ObjectPo ls.ObjectPool!(int, Memory.Allocators.DefaultAllocator).ObjectPool.Entry, Memory.Allocators.DefaultAllocator).Array))" (_D11Collections6Arrays__T5ArrayTSQBf11ObjectPools__T10ObjectPoolTiTS6Memory10Allocators16DefaultAllocatorZQCc5EntryTQBxZQDr8opAssignMFNcxSQFgQEw__TQEsTQEpTQDkZQFeZSQGgQFw__TQFsTQFpTQEkZQGe) 4HA)
Dec 08 2019
On Sunday, 8 December 2019 at 19:57:11 UTC, Marcel wrote:On Sunday, 8 December 2019 at 19:36:40 UTC, Mike Parker wrote:Ok, I found a way to make this work by writing "nothrow:" inside each struct and module. Is this normal?[...]extern(C) void main() { auto pool = ObjectPool!(int)(100); auto a = pool.Acquire; pool.Release(*a); } [...]
Dec 08 2019
On Sunday, 8 December 2019 at 19:29:23 UTC, Marcel wrote:Is it possible that exception code is being generated even though I have the -betterC flag enabled?Yes, a cleanup/finally is used, apparently in an opAssign. - These 2 symbols are apparently used to prevent too aggressive LLVM optimizations and are normally provided in druntime here [1]; you can add the 2 one-liners manually in a betterC project. [1] https://github.com/ldc-developers/druntime/blob/d363d27e119e7cc41b8fd5ef2145d8a7ad140080/src/ldc/eh_msvc.d#L593-L606
Dec 08 2019
On Sunday, 8 December 2019 at 20:58:44 UTC, kinke wrote:On Sunday, 8 December 2019 at 19:29:23 UTC, Marcel wrote:Perfect! Thank you very much!Is it possible that exception code is being generated even though I have the -betterC flag enabled?Yes, a cleanup/finally is used, apparently in an opAssign. - These 2 symbols are apparently used to prevent too aggressive LLVM optimizations and are normally provided in druntime here [1]; you can add the 2 one-liners manually in a betterC project. [1] https://github.com/ldc-developers/druntime/blob/d363d27e119e7cc41b8fd5ef2145d8a7ad140080/src/ldc/eh_msvc.d#L593-L606
Dec 08 2019