www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Does betterC work different on windows and linux?

reply Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
I was trying to make my stupid writeln2 function 
(https://github.com/aferust/stringnogc/blob/master/source/stringnogc.d)
compatible with betterC. writeln2() calls obParse() function which may contain
some code incompatible with betterC. However; while the code in the unittest
can be compiled and linked with betterC (extern (C) main...) on Ubuntu (LDC
1.17.0), it causes linking errors on windows (LDC 1.17.0):  unresolved external
symbol _D15TypeInfo_Struct6__vtblZ... I know that TypeInfo and ModuleInfo
features are unavailable with betterC. I want to know why my obParse() function
compiles and links on ubuntu but not on windows, and which part of my code
requires runtime.
Nov 14 2019
parent reply kinke <noone nowhere.com> writes:
I can't reproduce this with LDC 1.17.0, after changing `unittest` 
to `extern (C) int main()` and returning 0 at the end; compiled & 
linked with `ldc2 -betterC stringnogc.d`.
Nov 14 2019
parent reply Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
On Thursday, 14 November 2019 at 16:12:19 UTC, kinke wrote:
 I can't reproduce this with LDC 1.17.0, after changing 
 `unittest` to `extern (C) int main()` and returning 0 at the 
 end; compiled & linked with `ldc2 -betterC stringnogc.d`.
I could also run the code in that way. Probably I have some problems with dub configurations. I get linking errors when I try to import the library in a newly created dub project, although there is "dflags": ["-betterC"] in the dub.json of client app. Then we can be sure that it supports betterC.
Nov 14 2019
parent reply kinke <noone nowhere.com> writes:
On Thursday, 14 November 2019 at 16:34:07 UTC, Ferhat Kurtulmuş 
wrote:
 I could also run the code in that way. Probably I have some 
 problems with dub configurations. I get linking errors when I 
 try to import the library in a newly created dub project, 
 although there is "dflags": ["-betterC"] in the dub.json of 
 client app. Then we can be sure that it supports betterC.
The -betterC for that app doesn't imply that its dependencies are compiled with -betterC too. So either also specify that flag in your library's dub config, or build the app with `DFLAGS=-betterC dub ...`.
Nov 14 2019
parent Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
On Thursday, 14 November 2019 at 16:47:59 UTC, kinke wrote:
 The -betterC for that app doesn't imply that its dependencies 
 are compiled with -betterC too. So either also specify that 
 flag in your library's dub config, or build the app with 
 `DFLAGS=-betterC dub ...`.
Thank you, I added some information to the repo to use subConfigurations for betterC.
Nov 14 2019