Jump to content
  • Advertisement
Sign in to follow this  
SaurabhTorne

double includes of stdio.h

This topic is 3797 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!