below i have a code that runs in most of my simple programs .. .
i want to know if it’s good/bad … and cons/pros .
.
win32 header file:
win32.h
// example of a not realated code to exaplin the question
// this header have all win32 includes like win/proces/stdarg/string ... etc
#include <windows.h>
#include <process.h>
#include <stdarg.h>
main header file:
inc.h
//this file includes the following
//top : the windows header file
#include "win32.h" // include the win32.h header file
//the extern define which is the question
//the first include cause the INCS to be defined
//any include afterwards causes the DD to go from 'nothing' into 'extern'
#ifndef INCS
#define INCS
#define DD
#else
#define DD extern
#endif
// unrealted code to be more informative
//middle area of the file have the variables /defines or w/e
#ifndef VARS
#define titlen L"my program"
#endif
DD wchar_t gtitle[512];
DD wchar_t gclass[512];
DD wchar_t gdir[32767];
//last area of the file
// this bottom area have the project's files' all included all headers and code
#include "resources.h"
#include "commonfunctions.cpp"
then all files have something like this
commonfunctions.cpp
//a code just to be more informative and it's not realted to the question
#include "inc.h" // no need for includings ?
DD inline bool icmp( const char *String1, const char *String2 )
{
if ( _stricmp( String1, String2 ) == 0 ) { return true; }
return false;
}
DD inline bool scmp( const char *String1, const char *String2 )
{
if ( strcmp( String1, String2 ) == 0 ) { return true; }
return false;
}
DD refers to the #define DD extern
all global variables have DD infront of them and all functions/subs have DD too, that will cause the functions to be defined as extern in all file when included for the second time
is there a bad side of this ? . i came up with this idea and it wasn’t problematic at all in small programs . but before i apply it in a large project will it be problematic ?.
.
.
Now to the Question
DD here means the #define DD extern
DD will remove the need to do a psudo outside the code or in headers
DD will remove the need to define extern variables in each page
DD will remove the need to do the #includes of each header in each file
Now will this DD that is demostrated in the code upthere be a problem in a bigger code ?
edit:
i edited the question to be more clear
thanks in advance.
I think you are trying to automate the declaration of globals with extern and the single declaration without.
a) it is much simpler to have plain ‘extern’ in the header files and just have a cpp file called gtobals with the declarations in it
b) you dont need to do this for functions