How can I switch from my compiler invoking D1 to D2? I'd prefer to be using the more recent D2 - d

Is there a way to get my compiler to treat my code as if it were D2 code? I'm currently using dmd-2.084.0.exe to compile, Notepad++ as a de facto IDE while I come to grips with this language.

D1 has been deprecated in 2010 and the version number 2.084 tells you that you're using V2 of the DMD compiler. And 084 means that you're using the 84th major version of the compiler, which just has been published at 01.01.2019 and is the newest as I write this.
For completeness the last 0 is for patch releases which are published in between the bimonthly release cycle and contain just bug fixes and no new features.
What gives you the impression that you're using v1?

Related

Can I resurect removed std::result_of in MSVC 16.6 with some macro?

MSVC 16.6 in C++20 mode removes the result_of that was removed in C++20 standard.
I am all for doing the morally correct thing, but many 3rd party libraries(example) I use fail.
Sometimes MSVC enables users to define a define so that removed features are still enabled.
Is there an option to do that for result_of?
I have tried _HAS_FEATURES_REMOVED_IN_CXX20 and it seems to work, but the fact that macro starts with _ scares me, it suggests it may be internal MSVC mechanism and not something users should set.
Defining _HAS_DEPRECATED_RESULT_OF and _SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING should more granularly restore result_of and turn off its deprecation warning.
_HAS_FEATURES_REMOVED_IN_CXX20 and _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS should do the same for all C++17 features retired in C++20.
Given past history, these "deprecation overrides" should be relatively safe to use now and for some time coming. Below is an older quote (about VS 2017) from an MS sanctioned blog.
5. (Important!) It’s very likely that you’ll encounter source breaking changes in third-party libraries that you can’t modify (easily or at all). We try to provide escape hatches so you can restore removed features or silence deprecation warnings and get on with your work, but first, please report such issues to the relevant library maintainers. By helping them update their code, you’ll help many more C++ programmers just like you.

Time functions in mingw

I am trying to implement the code given in this page
http://msdn.microsoft.com/en-us/library/windows/desktop/aa366062%28v=vs.85%29.aspx
I am using mingw (gcc) to compile this.
But the following lines cannot be compiled. I have included 'time.h'. I searched but cannot locate this '_localtime31_s' or its equivalent in gcc.
error = _localtime32_s(&newtime, (__time32_t*) &pAdapter->LeaseObtained);
error = asctime_s(buffer, 32, &newtime);
Where is the time functions here?
Thanks
The functions localtime_s and asctime_s are Microsoft-specific extensions, provided by (certain versions of) the MS runtime library. This is provided by the MS header files. Since those are copyright MS and not allowed for free distribution, mingw provides its own versions of headers - and these probably don't contain these extensions (they certainly didn't a while back when I was using mingw on my local machine - my main machine these days runs Linux...).
Note that casting the time value to time32_t * is probably a bad idea - it is almost certainly going to bite you if you ever compile your code with a time_t that isn't a 32-bit value.
The localtime_r function is a semi-standard version that could be used instead of localtime_s (you will need to pay attention to 32 vs 64-bit time values). You can certainly also use localtime (aside from having to turn off MS's annoying "this function is not safe, please use ..._s instead" - I don't REALLY want to convert my 100 uses of strcpy to strcpy_s that work perfectly fine because it has already been checked elsewhere).
Similarly there is asctime_r which provides a re-entrant version.
You could, perhaps, also add the prototypes for these functions to your file somewhere, I believe that would, as long as you are compiling for Windows, solve the problem:
Link to MS function documentation: localtime_s and asctime_s.
MinGW-w64 provides an option to enable the secure CRT functions. Note there are compatibility issues with Windows XP, where msvcrt.dll does not contain these functions and your application will not work in that environment.
These are standardized in C11 Annex K, which is optional and may be missing on C11 conformant systems.

Major differences between Visual Studio 6.0 and VS 2010 Compilers

Some months ago I posted the following question
Problem with templates in VS 6.0
The ensuing discussion and your comments helped me to realize that getting my hands on a new compiler was mandatory - or basically they were the final spark which set me into motion. After one month of company-internal "lobbying" I am finally getting VS 2012 !! (thank you guys)
Several old tools which I have to use were developed with VS 6.0
My concerns are that some of these tools might not work with the new Compiler. This is why I was wondering whether somebody here could point out the major differences between VS 6 and VS 2012 - or at least the ones between VS 6 and VS 2010 - the changes from 2010 to 2012 are well documentes online.
Obviously the differences between VS 6.0 and VS 12 must be enormous ... I am mostly concerned with basic things like casts etc. There is hardly any information about VS 6.0 on the web - and I am somewhat at a loss :(
I think I will have to create new projects with the same classes. In the second step I would overwrite the .h and .cpp files with the ones of the old tools. Thus at least I will be able to open the files via the new compiler. Still some casts or Class definitions might not be supported and I would like to have a general idea of what to look for while debugging :)
The language has evolved significantly since VS 6.0 came out.
VS6.0 is pre-C++98; VS 2012 is C++03, with a few features from
C++11.
Most of the newer language features are upwards compatible;
older code should still work. Still, VC 6.0 is pre-standard,
and the committee was less concerned about breaking existing
code when there was no previous standard (and implementations
did vary). There are several aspects of the language (at least)
which might cause problems.
The first is that VC 6.0 still used the old scoping for
variables defined in a for. Thus, in VC 6.0, things like the following
were legal:
int findIndex( int* array, int size, int target )
{
for ( int i = 0; i < size && array[i] != target ; ++ i ) {
}
return i;
}
This will not compile in VC 2012 (unless there is also a global
variable i, in which case, it will return that, and not the
local one).
IIRC, too, VC 6.0 wasn't very strict in enforcing access
controls and const. This may not be problem when migrating,
however, because VC 2012 still fails to conform to C++98 in some
of the more flagrant cases, at least with the default options.
(You can still bind a temporary to a non-const reference, for
example.)
Another major language change which isn't backwards compatible
is name lookup in templates. Here too, however, even in VC
2012, Microsoft has implemented pre-standanrd name lookup (and
I mean pre-C++98). This is a serious problem if you want to
port your code to other compilers, but it does make migrating
from VC 6.0 to VC 2012 a lot easier.
With regards to the library, I can't remember whether 6.0
supported the C++98 library, or whether it was still
pre-standard (or possibly it supported both). If your code has
things like #include <iostream.h> in it, be prepared for some
differences here: minor for straight forward use of << and
>>; major if you implement some complicated streambuf. And
of course, all of the library was moved from global namespace to
std::.
For the rest: your code obviously won't use any of the features
introduced after VC 6.0 appeared. This won't cause migration
problems (since the older features are still supported), but
you'll doubtlessly want to go back, and gradually upgrade the
code once you've migrated. (You mentionned casts. This is
a good example: C style casts are still legal, with the same
semantics they've always had, but in new code, you'll want to
avoid them, and least when pointers or references are involved.)

How can I generate metadata output with clang similar to that of gcc-xml?

I found that GCCXML is not being maintained anymore (I think the last version is from 2009 from their CVS repository). People usually suggest to check out clang, but I couldn't find a comprehensive documentation that described how to generate a similar output. Not necessarily XML, but the same information in a parsable (documented, if binary or obscure) format. If there is a way to get the same information from a recent gcc version, that is also fine.
This is for a hobby project for dynamic invocation of C++ code. I know about similar projects (pygccxml, xrtti, openc++), but the point is to make it, for fun.
There used to be a way to print an xml dump with Clang but it was more or less supported and has been removed. There are developers options to get a dump at various stages, but the format is for human consumption, and unstable.
The recommendation for Clang users has always been code integration:
Either directly using Clang from C++, and for example use a RecursiveASTVisitor implementation
Or use libclang from C or C++.
Unlike gcc, clang is conceived as a set of a libraries to be reused, so it does not make much sense to try and write a parser for some clang output: it is just much more error-prone than just consuming the information right at the source.
You could use the Clang based CastXML to generate XML file.
https://github.com/CastXML/CastXML
You could code a GCC plugin, or better yet, a MELT extension, to do that. You'll need a GCC 4.6 or later version (4.7 is coming out soon).
However, extending GCC, either thru a plugin coded in C or better yet with an extension coded in MELT (a domain specific language suited to extend GCC) takes some time, because you need to understand and handle most of main GCC internal representations (Gimple and Tree-s).
If you want to use MELT, I'll be delighted to help you.

Does an R compiler to C/C++ exist?

I'm wondering about the best way to deploy R. Matlab has the "matlab compiler" (MCR). There has been discussion about something similar in the past for R that would compile R into C or C++. Does anyone have any experience with the R to C Compiler (RCC) that was developed by John Garvin at Rice?
I've looked into it, and it seems to be the only project that worked on compiling R code into executable code. And as far as I can tell, it isn't still being used.
[Edit 1:]: To be clear, I know that there are C and C++ (and Java, Python, etc.) interfaces to R (rJava, rcpp, Rpy, etc.). I'm wondering about specific ways to compile and deploy R code without installing R in advance.
[Edit 2:]: John Mellor-Crummey tells me that they're still working on RCC and hope to make it available in 4 months or so (at the earliest). I'll update this further if I find anything else out.
A byte code compiler will be part of the R 2.13 release. By default it is not used in this release but it is available; I expect the 2.14 release will by default byte compile all base and recommended packages. The compiler::compile help page and the R Installation and Administration Manual give some more details.
I had forgotten about the Rice project, it has been a while. I think the operational term here is stated at the top of the project page: Last Updated 3/8/06.
And we all know R changes a lot. So I have only the standard few pointers for you:
Luke Tierney, who not only knows a lot about R internals but equally about byte compilers, has been working on such a project. Nothing ready yet, and it would still work in conjunction with the standard R engine.
Stephen Milborrow has the Ra extension to R that works with his just-in-time compiler package jit
my Introduction to High-Performance Computing with R tutorials (most recent tutorial slides from UseR! 2009) covers the profiling, compiling extentions, parallel computing with R, ... part, including
Rcpp and and a bit about
RInside.
In short: there is no way have what you desire specific ways to compile and deploy R code without installing R in advance. Sorry.
Edit/Update (April 2011): Luke's new compiler package will be part of R 2.13.0 (to be released April 2011) but not 'activated' by default which is expected for R 2.14.0 expected for October 2011.
Edit/Update (December 2011): Prof Tierney just release a massive 100+ page paper on the byte-code compiler.
Why do people get the fear when deploying R? I'm fairly sure I've seen this question before.
Installing R is a piece of cake (you don't actually say which OS you care about). For Windows its one .exe. file, run it, say "yes" a few times and its done. I suspect the installer exe probably has flags for unattended installation too.
You may check out the P compiler which implements a subset of R. Especially, lists, matrices, vectors etc. are implemented as well as lsfit, chol, svd, ...
You can download a free version at
www.ptechnologies.org
It speeds up computations substantially.
Best,
AS
I haven't used Garvin's package and don't know what is possible along those lines. However:
Typically people just write computationally intensive functions directly in C/C++/Fortran, after profiling to find the bottlenecks. See the RCpp interface or Calling C functions from R using .C and .Call for examples. The Scythe Statistical Library is also very nice for R users since the syntax/function names are similar.