www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Using a betterC dub package in ordinary D

reply Bastiaan Veelo <Bastiaan Veelo.net> writes:
Hi,

When I use earcutd [1] in an ordinary D project, I get a link 
error for the __D7earcutd12__ModuleInfoZ symbol. This is because 
the earcutd dub.json has `"dflags": ["-betterC"]`. I think this 
is in error, my understanding of betterC code is that it can be 
compiled with "-betterC", but does not need to (and must not when 
used in D context).

Am I right? What are the best practices for betterC dub packages?

Thanks,
Bastiaan.


[1] https://code.dlang.org/packages/earcutd
Jan 08
parent reply Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
On Friday, 8 January 2021 at 15:40:12 UTC, Bastiaan Veelo wrote:
 Hi,

 When I use earcutd [1] in an ordinary D project, I get a link 
 error for the __D7earcutd12__ModuleInfoZ symbol. This is 
 because the earcutd dub.json has `"dflags": ["-betterC"]`. I 
 think this is in error, my understanding of betterC code is 
 that it can be compiled with "-betterC", but does not need to 
 (and must not when used in D context).

 Am I right? What are the best practices for betterC dub 
 packages?

 Thanks,
 Bastiaan.


 [1] https://code.dlang.org/packages/earcutd
Dear Bastiaaan, I am not an expert in dub system, but I have just pushed a modification in dub.json. I am not sure if it solves your problem. My modification is "configurations": [ { "name": "default", "targetType": "library" }, { "name": "betterC", "targetType": "library", "dflags": ["-betterC"] } ] now client projects must explicitly pass the subConfiguration parameter to compile it with betterC.
Jan 08
next sibling parent Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
On Friday, 8 January 2021 at 18:28:36 UTC, Ferhat Kurtulmuş wrote:
 On Friday, 8 January 2021 at 15:40:12 UTC, Bastiaan Veelo wrote:
 Hi,

 When I use earcutd [1] in an ordinary D project, I get a link 
 error for the __D7earcutd12__ModuleInfoZ symbol. This is 
 because the earcutd dub.json has `"dflags": ["-betterC"]`. I 
 think this is in error, my understanding of betterC code is 
 that it can be compiled with "-betterC", but does not need to 
 (and must not when used in D context).

 Am I right? What are the best practices for betterC dub 
 packages?

 Thanks,
 Bastiaan.


 [1] https://code.dlang.org/packages/earcutd
Dear Bastiaaan, I am not an expert in dub system, but I have just pushed a modification in dub.json. I am not sure if it solves your problem. My modification is "configurations": [ { "name": "default", "targetType": "library" }, { "name": "betterC", "targetType": "library", "dflags": ["-betterC"] } ] now client projects must explicitly pass the subConfiguration parameter to compile it with betterC.
I also added this: version(LDC){ version(D_BetterC){ pragma(LDC_no_moduleinfo); } } Docs say LDC_no_moduleinfo This pragma disables the generation of the ModuleInfo metadata to register the current module with druntime. Note that this, among other things, leads to any static constructors not being run, and should only be used in very specific circumstances. I used that pragma against an error, but I cannot remember what was that.
Jan 08
prev sibling parent reply Bastiaan Veelo <Bastiaan Veelo.net> writes:
On Friday, 8 January 2021 at 18:28:36 UTC, Ferhat Kurtulmuş wrote:
 On Friday, 8 January 2021 at 15:40:12 UTC, Bastiaan Veelo wrote:
 Hi,

 When I use earcutd [1] in an ordinary D project, I get a link 
 error for the __D7earcutd12__ModuleInfoZ symbol.
[...]
 Dear Bastiaan,

 I am not an expert in dub system, but I have just pushed a 
 modification in dub.json. I am not sure if it solves your 
 problem. My modification is

     "configurations": [
         {
             "name": "default",
             "targetType": "library"
         },
         {
             "name": "betterC",
             "targetType": "library",
             "dflags": ["-betterC"]
         }
     ]

 now client projects must explicitly pass the subConfiguration 
 parameter to compile it with betterC.
Much appreciated Ferhat! This works like a charm. I am kind of surprised that it does, as I expected dvector to need the same treatment. Excellent support by the way, thanks! Off topick, the original js implementation is documented to not generate results that are guaranteed to be correct. I could not find information on what the conditions are that cause deviations, and how large these then can be. Do you have an idea about this or experience with accuracy of the algorithm? I am looking into whether earcutd can replace GLU tesselation. We use the result for engineering purposes (not only visualisation) and correctness is important to us. Thanks! Bastiaan.
Jan 08
next sibling parent Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
On Friday, 8 January 2021 at 20:19:59 UTC, Bastiaan Veelo wrote:
 On Friday, 8 January 2021 at 18:28:36 UTC, Ferhat Kurtulmuş 
 wrote:
 On Friday, 8 January 2021 at 15:40:12 UTC, Bastiaan Veelo 
 wrote:
 Hi,

 When I use earcutd [1] in an ordinary D project, I get a link 
 error for the __D7earcutd12__ModuleInfoZ symbol.
[...]
 Dear Bastiaan,

 I am not an expert in dub system, but I have just pushed a 
 modification in dub.json. I am not sure if it solves your 
 problem. My modification is

     "configurations": [
         {
             "name": "default",
             "targetType": "library"
         },
         {
             "name": "betterC",
             "targetType": "library",
             "dflags": ["-betterC"]
         }
     ]

 now client projects must explicitly pass the subConfiguration 
 parameter to compile it with betterC.
Much appreciated Ferhat! This works like a charm. I am kind of surprised that it does, as I expected dvector to need the same treatment. Excellent support by the way, thanks! Off topick, the original js implementation is documented to not generate results that are guaranteed to be correct. I could not find information on what the conditions are that cause deviations, and how large these then can be. Do you have an idea about this or experience with accuracy of the algorithm? I am looking into whether earcutd can replace GLU tesselation. We use the result for engineering purposes (not only visualisation) and correctness is important to us. Thanks! Bastiaan.
Sorry, I don't have any information regarding the correctness of the algorithm. I just ported it doing cpp to d translations. My only usage of it for my hobby game[1]. However, it would be nice if you have another usage area to test it. I am using it with a similar purpose of glu Tessa lation in the game (I guess it is so, I am a beginner with opengl) 1: https://github.com/aferust/drawee
Jan 08
prev sibling parent Arjan <arjan ask.me.to> writes:
On Friday, 8 January 2021 at 20:19:59 UTC, Bastiaan Veelo wrote:
 Off topick, the original js implementation is documented to not 
 generate results that are guaranteed to be correct. I could not 
 find information on what the conditions are that cause 
 deviations, and how large these then can be. Do you have an 
 idea about this or experience with accuracy of the algorithm? I 
 am looking into whether earcutd can replace GLU tesselation. We 
 use the result for engineering purposes (not only 
 visualisation) and correctness is important to us.
I've used documentation and implementations from David Eberly at https://www.geometrictools.com/ and also on github nowadays to get 'correct' or at least 'predictable' behavior for various geometric challenges. Using this library solved various issues for us. The documentation is great!
Jan 08