double includes of stdio.h

Recommended Posts

Hi.Sort of a noob question here, I was checking out about this program where the includes are given as follows. I was thinking that the strsafe.h is included first which itself has included stdio.h then why the stdio.h is included again. Its confusing me a bit.
//..
//-----------------------------------------------------------------------------
#define STRICT
#define _CRT_SECURE_NO_DEPRECATE // Not recommended but need to support VS2003 and VS2005 for now
#include <windows.h>
#include <tchar.h>
#pragma warning( disable : 4996 ) // disable deprecated warning
#include <strsafe.h>
#pragma warning( default : 4996 )
#pragma warning(disable:4005)
#pragma warning(default:4005)
#include <stdio.h>
#include <stdlib.h>
#include <commctrl.h>
#include <assert.h>
#pragma warning( push, 3 )
#pragma warning(disable:4995 4786 4788)
#include <vector>
#pragma warning( pop )
using namespace std;
#include "dxdiaginfo.h"
#include "resource.h"
#if defined(DEBUG) | defined(_DEBUG)
#include <crtdbg.h>
#endif
//....


Share on other sites
what if strsafe changes in the future and no longer includes that file? A file should always explicitly include anything that it needs to function.

Share on other sites
well in that case strsafe.h is not that safe!
But if future compatible system is required then probably the file is bound to be there.

Share on other sites
strsafe provides certain functions if strsafe's job to provide a full stdio interface then the inclusion of stdio is redundant. However I don't believe this to be the case, and as such I would not rely on that behavior.

Share on other sites
Quote:
 Original post by SaurabhTornewell in that case strsafe.h is not that safe!But if future compatible system is required then probably the file is bound to be there.

That doesn't make strsafe.h unsafe. It provides safe versions of string manipulation routines.

Create an account

Register a new account

• Forum Statistics

• Total Topics
628347
• Total Posts
2982204

• 10
• 9
• 24
• 11
• 9