Note that there are some explanatory texts on larger screens.

plurals
  1. POc++ code cons/pros
    primarykey
    data
    text
    <p>below i have a code that runs in most of my simple programs .. .<br> i want to know if it's good/bad ... and cons/pros . </p> <p>.<br> win32 header file: <em>win32.h</em></p> <pre><code>// example of a not realated code to exaplin the question // this header have all win32 includes like win/proces/stdarg/string ... etc #include &lt;windows.h&gt; #include &lt;process.h&gt; #include &lt;stdarg.h&gt; </code></pre> <p>main header file: <em>inc.h</em></p> <pre><code>//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" </code></pre> <p>then all files have something like this <em>commonfunctions.cpp</em></p> <pre><code>//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; } </code></pre> <hr> <h2>DD refers to the #define DD extern</h2> <p>all global variables have <em>DD</em> infront of them and all functions/subs have <em>DD</em> too, that will cause the functions to be defined as extern in all file when included for the second time</p> <p>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 ?. . </p> <p>.</p> <h1>Now to the Question</h1> <p>DD here means the #define DD extern<br> DD will remove the need to do a psudo outside the code or in headers<br> DD will remove the need to define extern variables in each page<br> DD will remove the need to do the #includes of each header in each file </p> <p>Now will this DD that is demostrated in the code upthere be a problem in a bigger code ?</p> <p><em>edit:</em><br> i edited the question to be more clear</p> <p>thanks in advance. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload