August 10, 2013
On Tue, Aug 06, 2013 at 01:59:28AM +0200, Andre Artus wrote:
> 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'.
> 
> http://www.cplusplus.com/reference/cstdlib/strtold/
> 
> Compiling results in the following error:
> 
> Error	1	error C2556: 'longdouble strtold(const char *,char **)' :
> overloaded function differs only by return type from 'long double
> strtold(const char *,char
> **)'	d:\source\github\d\dmd\src\root\longdouble.h	201	1	dmd_msc
> 
> I have not used C++ in a very long time (cannot believe I used to
> love it, now it looks so ugly).
> 
> I can build against the VS2012 libraries, but that defeats the purpose of the exercise for me.
> 
> Is there a way to hide cstdlib/strtold?
[...]

One way that occurs to me, but which unfortunately as Very Ugly, is to #define strtold into something else. If standard lib headers are always #include'd first, and dmd internal headers after, then putting:

	#define strtold strtold_dmd

in the header in dmd that defines the function should fix the problem.

It *is* an extremely ugly hack, though. Now excuse me as I go to wash my hands... :-P


T

-- 
PNP = Plug 'N' Pray
August 10, 2013
On Tue, Aug 06, 2013 at 02:38:43AM +0200, Andre Artus wrote:
> >I could refactor the code to rename dmd/strtold, but that may not go down well (play nice with others).
> 
> I did a rename refactor on strtold (changed it to strtolongdouble) for S&G and everything seems to work just fine for VC++ 2013.

Nice, does it pass the unittests?


T

-- 
Lottery: tax on the stupid. -- Slashdotter
August 10, 2013
On Wed, Aug 07, 2013 at 12:58:16AM +0200, Andre Artus wrote:
> On Tuesday, 6 August 2013 at 22:38:58 UTC, bearophile wrote:
> >Andre Artus:
> >
> >>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 didn't talk about the strtosomething name, I was referring to everything else you have found, the warnings.
> >
> >Bye,
> >bearophile
> 
> Okay. I already changed those in my copy.
> Just out of interest: what would be an acceptable name to change
> 'strtold' to?

Maybe strtold_dmd? Or you could just post the pull request and let the reviewers suggest a better name if they don't like your choice. :)


T

-- 
"I'm not childish; I'm just in touch with the child within!" - RL
August 10, 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
1 2
Next ›   Last »