Jump to page: 1 2
Thread overview
Compiling DMD with C++11
Aug 05, 2013
Andre Artus
Aug 06, 2013
Andre Artus
Aug 06, 2013
Andre Artus
Aug 06, 2013
Andre Artus
Aug 10, 2013
H. S. Teoh
Aug 06, 2013
bearophile
Aug 06, 2013
Andre Artus
Aug 06, 2013
bearophile
Aug 06, 2013
Andre Artus
Aug 07, 2013
David Nadlinger
Aug 07, 2013
Andre Artus
Aug 10, 2013
H. S. Teoh
Aug 10, 2013
H. S. Teoh
Aug 10, 2013
H. S. Teoh
August 05, 2013
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?

I could refactor the code to rename dmd/strtold, but that may not go down well (play nice with others).

I also get the following warnings (when compiling in VS2012):

Warning	1	warning C4805: '!=' : unsafe mix of type 'char' and type 'bool' in operation	D:\source\GitHub\D\dmd\src\mars.c	1031	1	dmd_msc (Visual Studio 2012)

Warning	2	warning C4700: uninitialized local variable 'i' used	d:\source\github\d\dmd\src\backend\cgcod.c	2204	1	dmd_msc (Visual Studio 2012)

Warning	3	warning C4805: '==' : unsafe mix of type 'bool' and type 'int' in operation	D:\source\GitHub\D\dmd\src\backend\divcoeff.c	284	1	dmd_msc (Visual Studio 2012)

I tend to treat warnings as errors in my own code, which I relaxed here in order to get a working build.
August 06, 2013
I see there is quite a lot of code commented out with '#if 0', most of which looks like testing code. Unit tests in D is one of the 'killer' features. THE killer D feature for me is 'scope'.

I bring this up because I see

extern "C" longdouble strtold(const char *p,char **endp);
//strtold.c(583, 23):

is in one of those blocks. If 'strtold' had to change names who would be affected by it?
August 06, 2013
I forgot about the joys of C++, e.g. the code, build, make coffee, read forum posts, run, cycle.
August 06, 2013
> 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.
August 06, 2013
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
August 06, 2013
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.

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'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'. 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. 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.

August 06, 2013
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
August 06, 2013
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?
August 07, 2013
On Tuesday, 6 August 2013 at 22:58:21 UTC, Andre Artus wrote:
> Okay. I already changed those in my copy.
> Just out of interest: what would be an acceptable name to change 'strtold' to?

strtold is a C standard library function, but due to the portability problems the actual compiler code should use Port::strtold: https://github.com/D-Programming-Language/dmd/blob/master/src/root/port.h#L59 (OTOH, some backend/* code might pull it in directly, though).

As for what name to use for the internal implementation of Port::strtold on MSVC, you can pretty much pick whatever you like, as it shouldn't affect any other code.

David
August 07, 2013
On Wednesday, 7 August 2013 at 08:18:26 UTC, David Nadlinger wrote:
> On Tuesday, 6 August 2013 at 22:58:21 UTC, Andre Artus wrote:
>> Okay. I already changed those in my copy.
>> Just out of interest: what would be an acceptable name to change 'strtold' to?
>
> strtold is a C standard library function, but due to the portability problems the actual compiler code should use Port::strtold: https://github.com/D-Programming-Language/dmd/blob/master/src/root/port.h#L59 (OTOH, some backend/* code might pull it in directly, though).
>
> As for what name to use for the internal implementation of Port::strtold on MSVC, you can pretty much pick whatever you like, as it shouldn't affect any other code.
>
> David

I'm not near my Windows PC right now, but if memory serves the name clash occurs in the following places:

https://github.com/D-Programming-Language/dmd/blob/master/src/backend/strtold.c?source=cc#L138

https://github.com/D-Programming-Language/dmd/blob/master/src/root/longdouble.h#L201

https://github.com/D-Programming-Language/dmd/blob/master/src/backend/strtold.c#L567

I do not recall "Port::strtold" being a problem, other than that (if I recall correctly) it forwards to the conflicting function.

https://github.com/D-Programming-Language/dmd/blob/master/src/root/port.c#L118


« First   ‹ Prev
1 2