Compiling DMD with C++11

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Aug 6 15:30:16 PDT 2013


On Wed, Aug 07, 2013 at 12:10:33AM +0200, Andre Artus wrote:
> On Tuesday, 6 August 2013 at 16:18:54 UTC, bearophile wrote:
> >Andre Artus:
> >
> >>I decided to see whether dmd would compile with VS2013 and
> >>Clang. So far the only issue seems to be that C++11 RTL already
> >>defines 'strtold'.
> >
> >I suggest to put most of those small bug reports in Bugzilla (or
> >better if you want as a patch in GitHub to fix them).
> >
> >Bye,
> >bearophile
> 
> I 'fixed' it in my copy. By that I mean it compiles and runs on my
> system, but no code in other conditional compilation path has
> changed, so it will break say on *nix etc. I currently only work on
> Mac and Windows, my Linux & BSD boxes were stolen.

Did you run the test suite? If it passes the test suite, I'd say submit
a pull request to rename that function.


> If there is agreement with the new name, or if a better alternative
> is offered then I will be more than happy to make a comprehensive
> change.
> 
> I'm not sure if it classifies as a bug though, as there is no reason
> why DMD *has* to compile with C++11 libraries; it was just an
> experiment I tried.

I think it would only benefit us to have DMD compilable under C++11. I
know this currently isn't officially supported, but if it can be made to
work, why not?


> I'm not sure that "strtolongdouble" fits in with the naming
> convention but I decided to choose something that would be easy to
> grep if I needed to do so. The all lowercase convention prevalent in
> C causes a little bit of sick to rise in my throat every time I see
> it. When I first saw 'strtold' my brain picked up 'str to old', as
> opposed to 'str to l d'.

This is just sticking with the C library conventions (strtol, strtod,
etc.). Honestly, I prefer all lowercase identifiers; I find camelCasing
very jarring and unpleasant to the eye. But it's just a matter of
personal preference, so I can live with it. :)


> I normally try to write code in a way that someone with no prior
> experience may reasonably infer it's function merely from looking at
> the signature.

Anyone familiar with the standard C library strtol, strtod & co., will
have no problems correctly guessing what strtold does. It's just a
different convention from the prevalent camelCasing thing, that's all.

Of course, I wouldn't use such names when writing D code, but y'know, it
eventually just a matter of convention. :)


> I'll refactor several times if need be (while maintaining the contract
> on published interfaces where need be). But, when climbing into an
> established codebase it is prudent to follow existing conventions; I
> have not yet determined what they are for DMD.  I take it there is a
> doc or page up about that somewhere.

For Phobos & druntime there are established coding standards:

	http://dlang.org/dstyle.html

But since DMD is written in C++, I'd say just follow whatever prevalent
style is in the source code you're contributing to.


T

-- 
If you think you are too small to make a difference, try sleeping in a closed room with a mosquito. -- Jan van Steenbergen


More information about the Digitalmars-d mailing list