Header for CStdioFile , if I am already including windows.h - c++

Which header shall i use for CStdioFile?
The relevant doc is here
when I try including afx.h , i get following error( window.h is included before afx.h because of some other function):
Error 1 error C1189: #error : WINDOWS.H already included. MFC apps must not #include C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxv_w32.h
I wan to remain in native C++ world.
I am using visual studio 2013
If there is a basic setting in project properties that is relevant here, please let me know.

Related

Getting errors when include <WinSock2> on Visual Studio 2015

I'm trying to compile my project where I've just added the use of 'WinSock2.h'.I'm getting these errors :
c:\program files (x86)\windows kits\8.1\include\um\wingdi.h(2898): error C2208: '_POINTL' : no members defined using this type
c:\program files (x86)\windows kits\8.1\include\um\winuser.h(14564): error C2208: 'unsigned int' : no members defined using this type
more
I have searched solutions to my issue, I've added _WINSOCKAPI_ on preprocesseur rules and only the two errors up there are remaining. I have also tried adding WIN32_LEAN_AND_MEAN and still the same.
My project uses ALLEGRO library and "windows.h" file.
Have you a explanation of my problem ?
The compilator errors point to files winuser, wingdi, propild, oaidl.
These files has been added from the use of network library, on windows.h I guess.
The offending lines deal of following field definitions : unit, date, position.
All these name was already used on preprocessor definition on my project, leading to a conflict of definition.

Why do I get an error while compiling this code? [duplicate]

In my simple OpenGL program I get the following error about exit redefinition:
1>c:\program files\microsoft visual studio 8\vc\include\stdlib.h(406) : error C2381: 'exit' : redefinition; __declspec(noreturn) differs
1> c:\program files\microsoft visual studio 8\vc\platformsdk\include\gl\glut.h(146) : see declaration of 'exit'
I'm using Nate Robins' GLUT for Win32 and get this error with Visual Studio 2005 or Visual C++ 2005 (Express Edition). What is the cause of this error and how do I fix it?
Cause:
The stdlib.h which ships with the recent versions of Visual Studio has a different (and conflicting) definition of the exit() function. It clashes with the definition in glut.h.
Solution:
Override the definition in glut.h with that in stdlib.h. Place the stdlib.h line above the glut.h line in your code.
#include <stdlib.h>
#include <GL/glut.h>
or this...
To fix the error, right click on the project name in the Solution Explorer tab and select Properties -> C/C++ -> Preprocessor -> Preprocessor definitions and append GLUT_BUILDING_LIB to the existing definitions, seperated by semicolons.

redefinition of basic type when including external library

I am writing some code in c++ using Visual Studio 2013 to be referenced from within a .NET application from a CLR class library. The c++ componenent I am writing the wrapper for is Accusoft ImageGear. The problem that I am having is that when I include a header file in ImageGear I get the following compile error:
error C2371: 'AT_HANDLE' : redefinition; different basic
types C:\Program Files (x86)\Windows
Kits\8.1\Include\shared\windef.h 39 1 ImageGearWrapper
I also get the same error reported at lines 73,80,86,93 of windef.h.
I imagine that ImageGear must define a variable called AT_HANDLE, that is also defined in the Windows 8.1 SDK.
What can I do to resolve the conflict? I have read up on Include Guards, but not sure how to apply them in this case.
I noticed that if I create a Win32 console application, it still gives this error, but if I select "Include MFC" in the project wizard I no longer have the issue.

Identify which file has included some particular header file

Sometimes with a complex header structure it happens some header is included, but it is hard to tell where from.
Is there some tool (depedency viewer?) or a method how to find the "inclusion stack" (which source / which header / which header / ...) is including one particular header file?
If the header file is included multiple times, finding first inclusion is sufficient, finding all inclusions is a welcome bonus.
Someone has posted about it but I can't find this answer.
So, In VS, go to your project properties. Choose Configuration Properties / C/C++ / Advanced / Show Includes and set "yes".
then compile you cpp file. It looks like this:
cpp file:
#include <stdio.h>
int main()
{
return 0;
}
In the output window after compiling you will see:
1>------ Build started: Project: stlport_project, Configuration: Release Win32 ------
1>Compiling...
1>stlport_project.cpp
1>Note: including file: D:\src\hrs_rt_059.00\HRS\modules\src\libs\src\external\stlport\5.1.7\stdio.h
1>Note: including file: D:\src\hrs_rt_059.00\HRS\modules\src\libs\src\external\stlport\5.1.7\stl/_prolog.h
1>Note: including file: D:\src\hrs_rt_059.00\HRS\modules\src\libs\src\external\stlport\5.1.7\stl/config/features.h
and so on
EDIT: reference to the same question Displaying the #include hierarchy for a C++ file in Visual Studio
The header you are searching for may not be directly included into the source file. You need to 'preprocess_only' the code. This can be done in g++ by using the -E option; I don't know enough about visual C to know what the exact specification is there but if you look in the help for 'preprocess' you may come up with something.
A somewhat hacky approach (but one which should work on any platform/toolchain, without needing a separate dependency analyser) is simply to add a #error at the top of the included header - you will then get a compilation error from the first .cpp file which includes it.
Visual Studio /showIncludes
Directly in the Visual Studio I have found an option called /showIncludes - the output is textual only, but indented in a way which makes reading it quite easy:
Note: including file: /*..path.anonymized..*/\TCMalloc\windows\config.h
Note: including file: /*..path.anonymized..*/\memalloc\tcmalloc\windows/port.h
Note: including file: C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\windows.h
Note: including file: C:\Program Files\Microsoft Visual Studio 8\VC\include\excpt.h
Note: including file: C:\Program Files\Microsoft Visual Studio 8\VC\include\crtdefs.h
Note: including file: C:\Program Files\Microsoft Visual Studio 8\VC\include\sal.h
Note: including file: C:\Program Files\Microsoft Visual Studio 8\VC\include\vadefs.h
Note: including file: C:\Program Files\Microsoft Visual Studio 8\VC\include\stdarg.h
Note: including file: C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\windef.h
Note: including file: C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h
Note: including file: C:\Program Files\Microsoft Visual Studio 8\VC\include\ctype.h
Note: including file: C:\Program Files\Microsoft Visual Studio 8\VC\include\crtdefs.h
ProFactor Include Manager
There is also a VS add-in called Include Manager which seems to provide the needed functionality in a very nice visual way.

GLUT exit redefinition error

In my simple OpenGL program I get the following error about exit redefinition:
1>c:\program files\microsoft visual studio 8\vc\include\stdlib.h(406) : error C2381: 'exit' : redefinition; __declspec(noreturn) differs
1> c:\program files\microsoft visual studio 8\vc\platformsdk\include\gl\glut.h(146) : see declaration of 'exit'
I'm using Nate Robins' GLUT for Win32 and get this error with Visual Studio 2005 or Visual C++ 2005 (Express Edition). What is the cause of this error and how do I fix it?
Cause:
The stdlib.h which ships with the recent versions of Visual Studio has a different (and conflicting) definition of the exit() function. It clashes with the definition in glut.h.
Solution:
Override the definition in glut.h with that in stdlib.h. Place the stdlib.h line above the glut.h line in your code.
#include <stdlib.h>
#include <GL/glut.h>
or this...
To fix the error, right click on the project name in the Solution Explorer tab and select Properties -> C/C++ -> Preprocessor -> Preprocessor definitions and append GLUT_BUILDING_LIB to the existing definitions, seperated by semicolons.