Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: ollydbg on July 22, 2013, 08:36:56 am

Title: include of <prep.h>
Post by: ollydbg on July 22, 2013, 08:36:56 am
I see that we have a such way of include header files:

Code

 #include "sdk_precomp.h"
 
 #ifndef CB_PRECOMP
    #include "xxxx.h"
    #include "yyyy.h"
 #endif

If CB_PRECOMP is defined, then "xxxx.h" and "yyyy.h" was already in "sdk_precomp.h"
If CB_PRECOMP is NOT defined, then we should put "xxxx.h" and "yyyy.h" in the #ifndef branch.

Now, I see that "prep.h" is always included in "sdk_precomp.h" whether CB_PRECOMP is defined or not , so I think
1, we don't need to put #include<prep.h> in the #ifndef branch.
2, for consistency, I think all the cpp file should #include "sdk_precomp.h" instead of #include "<prep.h".

So, here is the patch. (in Git style)

Code
62efccccce054184a60d50417ff461f4dd639cf5
 src/sdk/cbauibook.cpp               | 1 -
 src/sdk/cbstyledtextctrl.cpp        | 1 -
 src/sdk/macrosmanager.cpp           | 2 +-
 src/sdk/nullptr.cpp                 | 2 +-
 src/sdk/pluginsconfigurationdlg.cpp | 1 -
 5 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/sdk/cbauibook.cpp b/src/sdk/cbauibook.cpp
index d355c7b..1ada6f1 100644
--- a/src/sdk/cbauibook.cpp
+++ b/src/sdk/cbauibook.cpp
@@ -11,7 +11,6 @@
 #include "sdk_precomp.h"
 
 #ifndef CB_PRECOMP
-    #include "prep.h"
     #include "cbauibook.h"
     #include "manager.h"
     #include "configmanager.h"
diff --git a/src/sdk/cbstyledtextctrl.cpp b/src/sdk/cbstyledtextctrl.cpp
index 7570d0d..e681604 100644
--- a/src/sdk/cbstyledtextctrl.cpp
+++ b/src/sdk/cbstyledtextctrl.cpp
@@ -20,7 +20,6 @@
     #include <wx/timer.h>
 
     #include "editorbase.h" // DisplayContextMenu
-    #include "prep.h" // platform::gtk
     #include "pluginmanager.h"
 #endif
 
diff --git a/src/sdk/macrosmanager.cpp b/src/sdk/macrosmanager.cpp
index 21389a4..f400651 100644
--- a/src/sdk/macrosmanager.cpp
+++ b/src/sdk/macrosmanager.cpp
@@ -33,7 +33,7 @@
 
 #include "scripting/sqplus/sqplus.h"
 #include "scripting/bindings/scriptbindings.h"
-#include "prep.h"
+
 #include "cbstyledtextctrl.h"
 
 using namespace std;
diff --git a/src/sdk/nullptr.cpp b/src/sdk/nullptr.cpp
index 4c36473..5c83259 100644
--- a/src/sdk/nullptr.cpp
+++ b/src/sdk/nullptr.cpp
@@ -7,7 +7,7 @@
  * $HeadURL$
  */
 
-#include <prep.h>
+#include "sdk_precomp.h"
 
 /* -----------------------------------------------
  * remove this once the compiler supports C++0x
diff --git a/src/sdk/pluginsconfigurationdlg.cpp b/src/sdk/pluginsconfigurationdlg.cpp
index ac73acb..21daacf 100644
--- a/src/sdk/pluginsconfigurationdlg.cpp
+++ b/src/sdk/pluginsconfigurationdlg.cpp
@@ -26,7 +26,6 @@
 #endif
 
 #include "annoyingdialog.h"
-#include "prep.h"
 #include <wx/dirdlg.h>
 #include <wx/filedlg.h>
 #include <wx/html/htmlwin.h>

Title: Re: include of <prep.h>
Post by: oBFusCATed on July 22, 2013, 09:46:00 am
Probably the patch should be done in the other way - make the inclusion of prep.h in sdk_precomp.h conditional.
Title: Re: include of <prep.h>
Post by: ollydbg on July 22, 2013, 10:13:13 am
Probably the patch should be done in the other way - make the inclusion of prep.h in sdk_precomp.h conditional.
It has a comment said that prep.h is deliberately(forced) included in sdk_common.h. (sdk_common.h is included in sdk_precomp.h)
Code
/*
 * This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
 * http://www.gnu.org/licenses/lgpl-3.0.html
 */

#ifndef SDK_COMMON_H
#define SDK_COMMON_H

//This file should be included only by sdk.h and sdk_precomp.h
//It includes all the common and necessary header files for precompilation.

/*
 * Enable backwards-compatibility for gcc 3.3 and lower.
 * Although the compiler does not support precompiled headers, the build might still use them.
 * We might significantly reduce the compile time for old compilers, by undefining CB_PRECOMP and thus
 * not including every header file twice.
 * This also allows us to reliably shortcut some includes for compilers that *do* support precompilation.
 */
#if defined(__GNUC__) && !defined(__APPLE__)
    #if ( (__GNUC__ < 3) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ < 4) ) )
        #undef CB_PRECOMP
    #endif
#endif // __GNUC__ && !__APPLE__

#if defined(NOPCH)
    #undef CB_PRECOMP
#endif // NOPCH

#if ( defined(CB_PRECOMP) && !defined(WX_PRECOMP) )
    #define WX_PRECOMP
#endif // CB_PRECOMP

// basic wxWidgets headers : this one itself will check for precompiled headers
// and if so will include a list of wx headers, at the bottom we add some more headers
// in the case of precompilation (note : some headers are in both lists)
// so even if NO CB_PRECOMP we can still have WX_PRECOMP turned on in this "wxprec" header
#include <wx/wxprec.h>

#ifdef __BORLANDC__
#pragma hdrstop
#endif

#include "prep.h" // this is deliberately not inside the #ifdef block

#ifdef CB_PRECOMP

    // some common wxWidgets headers
    #include <wx/arrstr.h>
    #include <wx/button.h>
    ....

You see:
Code
#include "prep.h" // this is deliberately not inside the #ifdef block

I don't know the reason.
Title: Re: include of <prep.h>
Post by: ollydbg on September 12, 2013, 06:56:18 am
I'm going to apply the patch, any comments on this? For those cpp files already include "sdk_precomp.h", I think there is not need to write a directive of include "prep.h", but if a cpp file don't need to include "sdk_precomp.h", then I think using include "prep.h" is OK, for example, in the nullptr.cpp, we can still use include "prep.h".
Title: Re: include of <prep.h>
Post by: ollydbg on September 13, 2013, 09:45:07 am
In trunk now.