Compiling DMD with C++11

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Aug 5 17:12:26 PDT 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


More information about the Digitalmars-d mailing list