Unittests and extern(C)

2017-06-21 Thread H. S. Teoh via Digitalmars-d
Never thought to mention these two things in the same subject line? Haha, well today I finally have reason to. This post is about an obscure bug I encountered today in one of my projects, with a moral lesson on why you really, really, ought to be using unittest blocks everywhere. First, a bit of a

Re: Unittests and extern(C)

2017-06-21 Thread Meta via Digitalmars-d
On Wednesday, 21 June 2017 at 22:19:48 UTC, H. S. Teoh wrote: Finally, the moral of the story is that had I written unittests for compile(), I would have caught this bug much earlier than I did. Also, DRY. Writing the same code more than once is always a recipe for disaster. It's bitten me so

Re: Unittests and extern(C)

2017-06-22 Thread Jacob Carlborg via Digitalmars-d
On 2017-06-22 00:19, H. S. Teoh via Digitalmars-d wrote: The code template says: extern(C) double funcImpl(double x, double y) But the function pointer type is declared as: alias FuncImpl = double function(double, double); Notice the lack of `extern(C)` in the latter. The cal

Re: Unittests and extern(C)

2017-06-22 Thread H. S. Teoh via Digitalmars-d
On Thu, Jun 22, 2017 at 10:16:51AM +0200, Jacob Carlborg via Digitalmars-d wrote: > On 2017-06-22 00:19, H. S. Teoh via Digitalmars-d wrote: > > > The code template says: > > > > extern(C) double funcImpl(double x, double y) > > > > But the function pointer type is declared as: > > > >