double includes of stdio.h

Started by
3 comments, last by dave 16 years, 2 months ago
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
//....
Advertisement
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.
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.
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.
Quote:Original post by SaurabhTorne
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.


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

This topic is closed to new replies.

Advertisement