VSCode missing std::as_const()? - c++

I have double checked several times that I am running either C++17 or above, yet this problem keeps occurring and I really don't understand why.
I am simply trying to call a const member function by using std::as_const(), which shouldn't be causing any fuss. Maybe it's missing from the utility library? But how could that be?
If anyone has an idea why this is happening I'd appreciate an answer.
VSCode telling me Utility library doesn't have std::as_const()

To summarize the back and forth in the comments:
Visual Studio Code relies on an external compiler to build and analize sources
Your compiler is the one that is likely old, not Visual Studio Code
Verify that your compiler is current
Update to a new compiler by upgrading MinGW.
In this case OP had an old compiler gcc 6.3.0 from Dec/2016 that did not support the features he wanted.

Related

Compiling MPI with mingw

I don't seem to be finding anything on this, or quite like this. I have this code that we want working with windows, so I've been using mingw and working to modify the code so it compiles. However, I ran into a big issue. The issue is entirely with Microsoft MPI. Our code includes and uses MPI for parallelization code. When the mingw compiler gets to the mpi portion, it tries to compile mpi.h and fails right away, because the overhead like (MPI_Offset and MPI_Count) are not declared in the header file (IIRC, they're usually done during compile time by mpicc or whatever, but MS-MPI doesn't do things that way, not really sure how it does things), it comes up with a bunch of "has not been declared" errors. How can I fix this? I really have no clue how MS-MPI works and the microsoft resources I've found do not help. I keep seein something about a cross platform mingw compiler, but I'm not sure what that is or how I'd use it. I have pretty much no experience compiling things outside of visual studio, and am only beginning to get familiar with mingw. Even pointers on where to look would be appreciated.
Interestingly enough, adding #include to the top of MS-MPI's mpi.h worked.
You may try mpich2. mpich2-v1.4.1p1 is the last version support windows officically. It also supports the MinGW and gfortran.
As stated in the mpich2's website, the msmpi is just a branch of mpich2 version 1.

Converting C++ code from VS 2005 to VS 2008? What does that even mean?

Ok, I kinda got an assignment, and I am not sure what it means.
The guy told me that I would be "converting" code from older version of VS to a newer one, not sure about the versions he really said, but lets take that these I said are correct.
Language is C++, and what am I supposed to do here? I mean, what are the differences in VS's?
Maybe I misunderstood what he said, but anyway I'm lost, help anyone?
The following would be the typical sequence of tasks:
Load the old VS2005 project file in VS2008
VS2008 will prompt to convert the project file to VS2008 format, do that
Build the project
Fix anything that is flagged as an error by the newer compiler
Test the resulting compiled code
Of course the C++ language itself did not change between those years. Other things about VS might have.

Compiling gRPC using MSYS2/Mingw32

I've come across an issue whilst trying to compile the latest branch of grpc under MSYS2, using mingw64 as suggested by the official installation guide.
The latest gcc for msys2 is 5.2.0, which isn't exactly on good terms with grpc. Still, downgrading to 4.9.1 helped a bit. Through a lot of manual editing of the makefile and a couple C headers, I was finally able to compile all the dependencies. As far as I can tell, most objects had successfully compiled. However, make keeps failing with the error "no target to make libgrp.dll, required by shared_c"(might not be perfect wording). I end up with botched static libs that are recognized by Qt as lacking symbols.
I would greatly appreciate a reliable compilation guide for grpc, and/or precompiled binaries fit for Qt 5.5 32-bit. I know the project is not too mature just yet, but it looks very promising and I can't wait to work with it!
Many thanks!
You're right that mingw isn't quite a first class citizen for grpc, but it's something we're looking to work on soon. Please file bugs at http://github.com/grpc/grpc/issues for anything you find!
That said, we do test the C codebase against Visual Studio 2013 regularly. I expect C++ to be tested regularly soon, along with VS2015. Could VS2015 be the solution to your problems, given it's now a free download?

How do I compile a directX tutorial sample in MingW

I have searched and searched and found no way to get directX to compile under MingW, I've seen others success and tried to replicate it to no avail. I've already read this similar question and it didn't help so please don't direct me to it: How to compile a DirectX 11 app in MinGW.
I've been trying to get MingW to cooperate with directX for a long time now, here is a list of my failed attempts and what I've read worked for others:
Download MSVC headers and have MingW use them
Download MingW-W64 and use it to compile
Download Reubens MingW-W64 and use it to compile
Download the most up to date MingW compiler and use it
Download TDM-GCC and use it.
mix compiler headers in a desperate attempt to make errors go away
I heard that I should be able to at least get to fail at the linker phase if I just dump the directX headers into the appropriate place, but I'm getting syntax errors left and right even after I did that (granted the bulk of them went away.) Each compiler ends up with its own unique errors, failing at different points but appearently succeeding in places where the others fail at some points. What is going on? Why does perfectly valid code (all written by microsoft) suddenly fail to compile when handled by any other compiler?
Unfortunately the samples include with the DirectX June 2010 SDK are far from "perfect valid code". They use a number of extensions specific to Microsoft's compiler.
Before I gave up on it as being essentially hopeless, I found the following Microsoft's specific dependencies when trying to compile the sample in Samples\C++\Direct3D\BasicHLSL:
the __noop intrinsic
the macros __min and __max
various "safe" versions of standard functions, like wsprintf_s and strcpy_s
non-standard pre-processor token pasting
allowing goto across variable initialization
the __uuidof operator
There are also problems with Microsoft's DirectX headers that I haven't mentioned, like being dependent on Microsoft's SAL annotation macros. Arguably though this a failing of MinGW for not having compatible versions of these DirectX headers.
Some of these problems are relatively easy to work around. Others are more difficult and would require rewriting the incompatible parts of the sample. There are also likely to be more Microsoft dependencies in the sample that I didn't discover.
The bottom line is that there's no way to compile the samples included with the DirectX SDK with MinGW or any other port of GCC without first modifying to the samples and the DXUT framework to make them more portable.

Converting VC++6/Win32 project to VS2010 C++/Win32 project: Known issues

Do you know of any resources highlighting known or possible issues during conversion of a VC++6/Win32 project to VS2010 C++/Win32 project type? I'm interested in all kinds of issues:
Compiler options compatibility
Compile-time issues
Link-time issues
Runtime issues
MFC issues
Otherwise, if you already performed that kind of migration, what issues have you encountered?
Thank you
VC++6 has non-standard exception handling. We hit a few problems because our code contain this:
try {
//Some code
}
catch (...) {
//Handle error
}
Some developers had relied on this broken behaviour and our application crash badly after being compiled in VS2008.
This article explains it well and how to solve the issue.
First of all, these issues are highly dependent on code quality and how the ancient code has been adapted to fit the VC++6 compiler's "features".
It's not possible to convert .dsp to the VS 2010 format directly (at least with the express editions), you'll have to pass through 2008 to be able to convert.
The conversion wizards should warn and inform you of any issues there might be. I haven't been through this process, but I would think compiler switches are the least of your worries. In general, I would expect bad code to produce a lot more errors you need to worry about instead.
As to your specific queries:
See 3.
VS2010 will take longer.
VS2010 linker will take longer, especially if you enable link-time optimization (introduced in VS 2005)
only if you made non-standard assumptions or if VC++6 has non-standard functions. As long as you recompile the complete project with VS2010 (and thus link it to the latest VC(++) runtime), no runtime issues should occur.
sidenote: I'm not saying the old code is bad, just that a lot of questions on SO regarding VC++6 are caused by bad code quality/conformance.
Heh, vs6 allowed you to use loop variables outside the scope of the loop. ie:
for ( int i=0; i<10; i++ )
{
if( i == 5 )
break;
}
int iVal = i;
This will fail in anything > vs6 :) fails in 2005 and 2010 - although there is a compiler setting that will allow you to force this behavior again (I would suggest just fixing it, don't force it, its noncompliant anyhow), at least in vs2005. I haven't made the dive to 2010 yet, as I do a lot of embedded development, and it seems switching compilers for the embedded stuff is usually a major pain. So, I can't say too much for 2010, but I know that carries through!
Did the move, two painful issues I'm aware of:
- The exception handling default was changed between VC6 and later versions. I believe /Eh was the default and that has changed.
- VC6 runtime (msvcrt DLL) is included in any Windows OS since Win2k, while for any other version you need to install it with your software for almost any OS.
You will have a lot of problems because VC6 was notoriously non-conformant, and your code (especially if you used templates) will likely be full of hacks to make it work that no longer are necessary, as MS did a lot of conformance work for more recent compiler versions, and the VC10 compiler will probably barf on them.
If you have a commercial edition of Visual C++:
Find devenv within your Visual C++ install directory (should be %VS90COMNTOOLS%\..\IDE\devenv.exe
> devenv /upgrade project.sln
> msbuild.exe project.sln /t:Build /p:Configuration=Release /p:Platform=Win32
Check the compilation
but If you have a free edition of Visual C++:
Find vcbuild.exe within your Visual C++ install directory (should be %PROGRAMFILES%\Microsoft Visual Studio 9.0\VC\vcpackages\vcbuild.exe)
> vcbuild.exe /upgrade project.sln
/msbuild:Configuration=Release
/msbuild:Platform=Win32
For future builds which don’t need conversion, type:
> msbuild.exe project.sln /t:Build /p:Configuration=Release /p:Platform=Win32
When moving from VS2005 to VS2010, we ran into a problem with a 3rd party library causing one of our programs to crash every time it was loaded. The problem turned out to be caused by Microsoft reversing the default setting for the /NXCOMPAT switch in the linker. That switch controls whether or not Data Execution Prevention (DEP) is enabled or not. Prior to VS2010, the default setting for that switch was NO and the DLL we were using apparently relied upon that setting to function correctly.
I'm not sure how far back the NXCOMPAT linker switch goes. It wasn't listed in any of the settings available in the VS2005 dialogs but it was listed when link /help was run from the command line. I've never been able to find a list of changes such as this from Microsoft, so this kind of bug is VERY tricky to track down.
If you're migrating from VC++ 6 to VS2015 with CLR, existing min and max functions are no longer found, add
#define NOMINMAX
#include <algorithm>
namespace Gdiplus
{
using std::min;
using std::max;
};
Secondly, NAN float changed to nan