Code that worked great in older versions of Visual Studio no longer compile. For example:
#include <fstream.h>
#include <iostream.h>
no longer compile. I'm trying to read in a binary data file using VC++ and VS2010. Why do such basic tools no longer work?
Don
In C++ (at least according to modern standards), you don't have to write the extensions of the standard header files:
#include <fstream>
#include <iostream>
Some compilers will just generate warnings when you write the extension, but I guess new versions of Visual treat it as an error.
Related
I have a C++ project that references many other projects/libraries. This is for an application that was created many years ago. About every once a year it is updated and a new version is done. I've used Visual Studio 6 to update and build new versions of this app for years now without any problems.
I am trying to switch to Visual Studio 10 (and now VS2013). Initially I ran into several warnings and errors which were due to compatibility issues between the VS versions. I was able to take care of most. However, I'm still somewhat confused by the following error:
error C1189: #error : MFC does not support WINVER less than 0x0501. Please change the definition of WINVER in your project properties or precompiled header. C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxv_w32.h
The error occurs in a few of the referenced project libraries. I checked the project libraries in question and I cant find any reference to WINVER.
I have searched the internet for info on this and found some topics but nothing that is specific to my problem. Can someone shed some light as to what might be happening here?
Thanks in advance.
LA
All MFC apps define the WINVER macro value somewhere if you didn't define it yourself. I assume MS has removed the definition by default on its own header files and is now making mandatory that you explicitly define it.
So, to solve your problem, either put the #define in your 'preprocessor' compiler options, or at the top of your precompiled header (ie stdafx.h).
Note 0x501 is Windows XP support. 0x600 is Vista, 0x601 is Windows 7 — and how sad am I for remembering that!
I got the same error, on Windows 7 with Visual Studio 2013.
In my case my project had a source file with name stdafx.h, inside that file there was
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif
I changed it to
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x601
#endif
and the error disappeared.
By default WINVER is defined as 0x0500 in preprocessor. To overcome from this error, remove defined win version "WINVER=0x0500" from
Configuration Properties => c/c++ => Preprocessor tab and rebuild.
Or you can provide higher WIN VERSION as #define _WIN32_WINNT 0x601 in your code wherever you getting error.
I recently switched from Visual Studios 2013 on Windows to Qt Creator on Ubuntu. Where can I find the header files for algorithm.h and math.h?
In Visual Studios I can simply just go to the Solutions Explorer and look at the dependencies.
You can place the cursor on math.h in #include <math.h> then press F2.
STL headers (like algorithm) have no extension in normal systems (i.e. non-MSVC), so #include <algorithm> instead of algorithm.h.
I am trying to build a C code which originally is built on linux with
gcc -lm ... option, which uses the math library while linking the code. How do I use the same in project settings of a Visual Studio 2005 compiler, on Win32 environment, to link the math library. Will just saying
#include "math.h"
be enough or i need to give math library as a dependency in the VS-2005 project settings, If yes then what is the setting for that?
Basic problem is when in my windows build, I include math.h but I get a compilation error: nanf():- identifier not found
I am looking to resolve this.
thank you,
-AD
#include "math.h" works fine on VS2005.
See Floating-Point Support.
When I type
#include <QObject>
it complains that it couldn't find file.
but if I type
#include <QtCore\QObject>
It works properly.
I moved VS2005 to VS2008, this was not the case in VS2005, and it started with VS2008. Why am I getting this error?
Actually it's not so big problem. You need to check you include directories and add (path_to_qt_headers)/QtCore, (path_to_qt_headers)/QtGui and directories for other modules you are using. According to your problem description you have added only (path_to_qt_headers) itself.
If Qt set up correctly both #include <QObject> and #include <QtCore/QObject> should work but second one works in more cases. I remember I saw some notice somewhere in the Qt documentation that it might be better to using second include style. At the same time this long include version is recommended in the KDE coding guidelines.
For myself I preffere to follow #include <QtModule/QClass> include convention
Maybe installing the Visual Studio addin for Qt would solve the problem (besides providing advanced debug and Qt project management tools).
Is there a quick way to determine whether a Visual Studio C++ project is written in plain C++ or Visual C++?
If any files include the lines #pragma once or #include "stdafx.h", it's very likely Visual C++.
(Are there any other compilers that implement #pragma once?)
No -- Visual C++ will compile most plain C++ without any problems. If you want to check for use of Windows-specific "stuff", checking for inclusion (directly or indirectly) of <windows.h> would probably be a reasonable start.
If is Visual C++ it usually has a project.sln or project.vcproj file in the project directory.