How is _isnan different to std::isnan on Visual Studio 2015 - visual-studio

Visual Studio 2015 offers _isnan and std::isnan to check if a double is NaN.
Following VS's 'Go to Definition' does not end up in the same place for both functions and assembly output from a simple program that checks for NaN is not the same.
How is _isnan different to std::isnan? Which should I use when writing C++?

_isnan is from Global Name Space which uses #include <float.h>
std::isnan is from Standard Name Space which uses #include <cmath>
You can use any one of them with Visual Studio 2015. Doesn't matter.
Refer this for more on this

From private communication with James McNellis of Microsoft (posted with approval):
"They were integrated into the C Runtime at different points in time. _isnan was integrated some time ago along with a handful of other IEEE recommended functions; isnan was added later as part of the C99 additions.
If you find a case where either produces an incorrect result, please do file a bug at https://connect.microsoft.com/visualstudio/."
I conclude from this that _isnan and std::isnan should do the same thing.

Related

std::aligned_alloc() missing from visual studio 2019?

Even though I did try enabling both std:c++latest and also c++17 separately, I couldnt use the std::aligned_alloc() function added in c++17. Is this real life? Did visual studio 2019 just flat out not implement an age old feature like this one in the standard(and a pretty important one too)? Can someone else confirm?
the feature I refer to:
https://en.cppreference.com/w/cpp/memory/c/aligned_alloc
From the Microsoft C++ language conformance table for VC++ 2019:
C11 - The Universal CRT implemented the parts of the C11 Standard Library that are required by C++17, with the exception of C99 strftime() E/O alternative conversion specifiers, C11 fopen() exclusive mode, and C11 aligned_alloc(). The latter is unlikely to be implemented, because C11 specified aligned_alloc() in a way that's incompatible with the Microsoft implementation of free(): namely, that free() must be able to handle highly aligned allocations.
VC++ has the compiler specific _aligned_malloc for memory aligned to power of 2 values, and see also What can I use instead of std::aligned_alloc in MS Visual Studio 2013?
.

A workaround for C++/CLI intellisense and System namespace

I have been working with standard C++ on Visual Studio for a while, and now I decided to try writing applications. I encountered the problem that in Windows Forms Applications intellisense was "Unavailable for C++/CLI". So I looked up what could be done and I found I could disable "\clr" from the options. So I did that.
Now the compiler complains that the using namespace System; directive fails at finding the namespace System.
Now, uncle Google seems to tell everyone to turn back on the \clr support which I am trying to avoid.
So my question is, where does the namespace live in, so that I can include its header or some other workaround so I can work with the little intellisense left by MS and live with it, as a tool such a Visual Assist is only for free for a limited time.
Thanks, and sorry if the question is disturbingly simplistic
System is a .NET Framework namespace and therefore will require the CLR option when compiling source that uses it.
Are you looking for using namespace std for command line applications?
You will need the /CLR (forward slash) option on to use the .NET frameworks. Visual Studio 2008 has better (not perfect, but livable) Intellisense for C++/CLI. If you don't need any newer features, that might be a better option for you.

Why are functions that belong to a class not showing in Visual C++?

I'm using Visual C++ in Visual Studio 2010 Express, and in the past I remember when you use a string object and after the dot (eg: .) all the member functions will show in list, but that's not happening.
string myString = "hello world";
myString.
After typing the dot, all functions that are part of the string class don't show. Where in Visual C++ is the setting to make them show?
The functionality you refer to is called IntelliSense in Microsoft-speak, their version of autocompletion for variable names, functions, and methods.
IntelliSense is not supported in Visual Studio 2010 for C++/CLI projects. You will only get IntelliSense for projects written in native C++ code. This is explained in more detail here on the Visual C++ Team Blog. There is also a bug filed on Microsoft Connect; the official word is this:
Thanks for your feedback. Unfortunately in this release we had to cut the intellisense support for C++/CLI due to time constraints. If you want to get some intellisense like quick info and memberlist on the native classes you can get it by choosing no /clr support in the project properties.
Thank You!
Visual C++ Team
This is unfortunate news for many of us who work with C++/CLI projects, and we aren't left with many options. A question regarding those options has been asked here: What are people replacing the missing C++/CLI Intellisense in VS 2010 with? The summary is people are either going back to VS 2008
(I believe the Express Edition of 2008 is still available for download if you look around), or purchasing third-party software such as Visual Assist X that promises to bring back IntelliSense.
It's worth mentioning, however, that Microsoft does not regard C++/CLI as a "first-class" .NET language. There's little (if any) reason to start new projects using the language. It's designed for interop purposes between native C++ and managed C# applications. If you want to write C++, you should target the native Windows API (create a new Win32 project in VS). If you want to write managed .NET code, it is highly recommended that you use C# instead (that's a different version of Express that must be downloaded separately). The syntax is very similar between C++ and C#, but you will still have to learn the .NET Framework and idioms. Both native C++ projects and managed C# projects have very much improved IntelliSense support in Visual Studio 2010, so you're guaranteed to be much happier with either of those.

Is there any predefined macro like _MSC_BUILD(supported from vs2008) in visual studio 2005?

I hope for using any predefined macro like _MSC_BUILD (from vs2008) because I want to use revision number of compiler.
but i can't find that in vs2005.
thank you for your help.
The predefined macros list for VS 2005 shows _MSC_VER for getting the compiler versions.
There were no (accessible) revision numbers in the days of VS2005, so sadly, no there isn't. See the following web site for a full list of available macros:
http://msdn.microsoft.com/en-us/library/b0084kay(VS.80).aspx

Visual Studio 2008 not detecting Errors while coding

I just installed VS on another PC, but this time, while I am coding, it is not marking syntax errors while I am coding..... I need to press F6 to get the errors.
Normally when for example typing the line below, I get 's' underlined saying that there is a mismatch. Any ideas how I can enable this option?
string s = 4;
In order to enable background compilation for C#, which checks you code while typing for many types of errors that are usually only reported when you build the project, you will have to install Service Pack 1 for Visual Studio 2008. If you use the offline MSDN, you will also want to install the updated MSDN Library for Visual Studio 2008 SP1, since there were framework changes from .NET 3.5 RTM to .NET 3.5 SP1 (such as the addition of Entity Framework).
Have you recently deinstalled ReSharper?
(see responses in the same link for other possibilities).
C# has never been as consistent about finding errors while i type as VB.net has. I always assumed it was just due to the freeform nature of the language, which would also explain why C++ never found errors either til build time.

Resources