Author Topic: My research on improving Auto Detection of Compilers  (Read 6738 times)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
My research on improving Auto Detection of Compilers
« on: January 21, 2012, 06:35:52 am »
I spent the last few hours helping "eb" on a CygWin Compiler issue.

I decided it was time to update the CompilerCYGWIN::AutoDetectInstallationDir method.

Here's the patch. I tested it as much as I can on just my Computer.
Edit: I plan to test it at School to see if it works on a 64 Bit Machine.
Edit: I have already thought up two changes to this patch.
Edit: I have decided that much more research is needed.



Tim S.

« Last Edit: January 21, 2012, 04:44:13 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: My research on improving Auto Detection of Compilers
« Reply #1 on: January 21, 2012, 05:46:45 pm »
Patch to get auto detect for Cygwin working.
Not as good as I wanted; I need to change the CB SDK to get more improvements.

Tim S.

Submitted as [ Patch #3249 ] Cygwin Compiler Autodetect fix https://developer.berlios.de/patch/?func=detailpatch&patch_id=3249&group_id=5358

Code
Index: src/plugins/compilergcc/compilerCYGWIN.cpp
===================================================================
--- src/plugins/compilergcc/compilerCYGWIN.cpp (revision 7711)
+++ src/plugins/compilergcc/compilerCYGWIN.cpp (working copy)
@@ -35,9 +35,11 @@
 {
     CompilerMINGW::Reset();
 
-    m_Programs.C = _T("gcc.exe");
-    m_Programs.CPP = _T("g++.exe");
-    m_Programs.LD = _T("g++.exe");
+    // NOTE: Cygwin's gcc.exe is a file link and
+    // is not a good default name for running via cmd.exe
+    m_Programs.C = _T("gcc-3.exe");
+    m_Programs.CPP = _T("g++-3.exe");
+    m_Programs.LD = _T("g++-3.exe");
     m_Programs.DBG = _T("gdb.exe");
     m_Programs.LIB = _T("ar.exe");
     m_Programs.WINDRES = _T("windres.exe");
@@ -48,24 +50,60 @@
     m_Options.AddOption(_("Do not use cygwin specific functionality"), _T("-mno-cygwin"), _("General"));
 }
 
+bool isCygwinSymbolicLink(const wxString& filename){
+    if (wxFileExists(filename)){
+        wxFile aFile(filename);
+        char buffer[11];
+        aFile.Read(buffer,10);
+        if (strcmp("!<symlink>", buffer) == 0){
+            return true;
+        }
+    }
+    return false;
+}
+
 AutoDetectResult CompilerCYGWIN::AutoDetectInstallationDir()
 {
-    m_MasterPath = _T("C:\\Cygwin"); // just a guess
+    AutoDetectResult ret = adrGuessed;
+    wxString tempMasterPath = _T("C:\\Cygwin"); // just a guess
+    m_MasterPath = tempMasterPath;
 
     // look in registry for Cygwin
 
     wxRegKey key; // defaults to HKCR
-    key.SetName(_T("HKEY_LOCAL_MACHINE\\Software\\Cygnus Solutions\\Cygwin\\mounts v2\\/"));
+    key.SetName(_T("HKEY_LOCAL_MACHINE\\Software\\Cygwin\\setup"));
     if (key.Exists() && key.Open(wxRegKey::Read))
     {
-        // found; read it
-        key.QueryValue(_T("native"), m_MasterPath);
+        // found CygWin version 1.7 or newer; read it
+        key.QueryValue(_T("rootdir"), tempMasterPath);
+        wxString cProgram = tempMasterPath + wxFILE_SEP_PATH +
+            _T("bin") + wxFILE_SEP_PATH + m_Programs.C;
+
+        if (wxFileExists(cProgram)){
+            wxFile testFile(cProgram);
+            if (!isCygwinSymbolicLink(cProgram)){
+                ret = adrDetected;
+            }
+        }
     }
-    AutoDetectResult ret = wxFileExists(m_MasterPath + wxFILE_SEP_PATH +
-                                        _T("bin") + wxFILE_SEP_PATH +
-                                        m_Programs.C)
-                            ? adrDetected
-                            : adrGuessed;
+    if (ret == adrGuessed){
+        key.SetName(_T("HKEY_LOCAL_MACHINE\\Software\\Cygnus Solutions\\Cygwin\\mounts v2\\/"));
+        if (key.Exists() && key.Open(wxRegKey::Read))
+        {
+            // found CygWin version 1.5 or older; read it
+            key.QueryValue(_T("native"), tempMasterPath);
+            if (wxFileExists(
+                    tempMasterPath + wxFILE_SEP_PATH +
+                    _T("bin") + wxFILE_SEP_PATH + m_Programs.C
+                )
+            ){
+                ret = adrDetected;
+            }
+        }
+    }
+    if (ret == adrDetected){
+        m_MasterPath = tempMasterPath;
+    }
     return ret;
 }
 
« Last Edit: January 21, 2012, 05:49:44 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: My research on improving Auto Detection of Compilers
« Reply #2 on: January 21, 2012, 06:32:50 pm »
I need to change the CB SDK to get more improvements.
...but your patch doesn't change the SDK, does it?! ???
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: My research on improving Auto Detection of Compilers
« Reply #3 on: January 21, 2012, 10:37:41 pm »
I need to change the CB SDK to get more improvements.
...but your patch doesn't change the SDK, does it?! ???

The patch submitted does not and the patch in this thread does not.
But, I am working on one that will require very minor changes to the SDK.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: My research on improving Auto Detection of Compilers
« Reply #4 on: January 22, 2012, 01:54:20 am »
Re-wrote logic till I found my bug (I used strcmp instead of memcmp)

A re-write of the Auto detection of CygWin Compiler patch (does NOT require or do SDK changes).

I am having issues getting the patch that requires the SDK changes to work right.

Tim S.

Updated patch 23Jan2012; planning to test it on 64 bit computers today.
Code
Index: src/plugins/compilergcc/compilerCYGWIN.cpp
===================================================================
--- src/plugins/compilergcc/compilerCYGWIN.cpp (revision 7711)
+++ src/plugins/compilergcc/compilerCYGWIN.cpp (working copy)
@@ -35,9 +35,11 @@
 {
     CompilerMINGW::Reset();
 
-    m_Programs.C = _T("gcc.exe");
-    m_Programs.CPP = _T("g++.exe");
-    m_Programs.LD = _T("g++.exe");
+    // NOTE: Cygwin's gcc.exe is a file link and
+    // is not a good default name for running via cmd.exe
+    m_Programs.C = _T("gcc-3.exe");
+    m_Programs.CPP = _T("g++-3.exe");
+    m_Programs.LD = _T("g++-3.exe");
     m_Programs.DBG = _T("gdb.exe");
     m_Programs.LIB = _T("ar.exe");
     m_Programs.WINDRES = _T("windres.exe");
@@ -48,24 +50,68 @@
     m_Options.AddOption(_("Do not use cygwin specific functionality"), _T("-mno-cygwin"), _("General"));
 }
 
+bool isNormalFileNotSymlink(const wxString& filename){
+    if (wxFileExists(filename)){
+        wxFile aFile(filename);
+        if (aFile.IsOpened()){
+            char buffer[10]={0};
+            aFile.Read(buffer,10);
+            if (memcmp("!<symlink>", buffer, 10) != 0){
+                return true;
+            }
+        }
+    }
+    return false;
+}
+
 AutoDetectResult CompilerCYGWIN::AutoDetectInstallationDir()
 {
-    m_MasterPath = _T("C:\\Cygwin"); // just a guess
+    AutoDetectResult ret = adrGuessed;
+    wxString tempMasterPath = _T("C:\\Cygwin"); // just a guess
+    m_MasterPath = tempMasterPath;
+    bool validInstallationDir = false;
 
     // look in registry for Cygwin
 
     wxRegKey key; // defaults to HKCR
-    key.SetName(_T("HKEY_LOCAL_MACHINE\\Software\\Cygnus Solutions\\Cygwin\\mounts v2\\/"));
+    key.SetName(_T("HKEY_LOCAL_MACHINE\\Software\\Cygwin\\setup"));
     if (key.Exists() && key.Open(wxRegKey::Read))
     {
-        // found; read it
-        key.QueryValue(_T("native"), m_MasterPath);
+        // found CygWin version 1.7 or newer; read it
+        key.QueryValue(_T("rootdir"), tempMasterPath);
+        if (wxDirExists(
+                tempMasterPath + wxFILE_SEP_PATH +
+                _T("bin"))
+        ){
+                validInstallationDir = true;
+        }
     }
-    AutoDetectResult ret = wxFileExists(m_MasterPath + wxFILE_SEP_PATH +
-                                        _T("bin") + wxFILE_SEP_PATH +
-                                        m_Programs.C)
-                            ? adrDetected
-                            : adrGuessed;
+    if (!validInstallationDir){
+        key.SetName(_T("HKEY_LOCAL_MACHINE\\Software\\Cygnus Solutions\\Cygwin\\mounts v2\\/"));
+        if (key.Exists() && key.Open(wxRegKey::Read))
+        {
+            // found CygWin version 1.5 or older; read it
+            key.QueryValue(_T("native"), tempMasterPath);
+            if (wxDirExists(
+                    tempMasterPath + wxFILE_SEP_PATH +
+                    _T("bin")
+                )
+            ){
+                validInstallationDir = true;
+            }
+        }
+    }
+
+    if (validInstallationDir){
+        wxString cProgramDir = tempMasterPath + wxFILE_SEP_PATH +
+            _T("bin") + wxFILE_SEP_PATH;
+        wxString cProgramFullname = cProgramDir + m_Programs.C;
+        if (isNormalFileNotSymlink(cProgramFullname)){
+            m_MasterPath = tempMasterPath;
+            ret = adrDetected;
+        }
+    }
+
     return ret;
 }
 

« Last Edit: January 23, 2012, 01:47:16 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: My research on improving Auto Detection of Compilers
« Reply #5 on: January 22, 2012, 11:49:00 pm »
The part of my future patch that changes any of the CB SDK

Code
Index: src/include/compiler.h
===================================================================
--- src/include/compiler.h (revision 7711)
+++ src/include/compiler.h (working copy)
@@ -142,7 +142,9 @@
 enum AutoDetectResult
 {
     adrDetected,
-    adrGuessed
+    adrGuessed,
+    adrDetectedDir,
+    adrDetectedToolChain
 };
 
 /// Struct to keep programs

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: My research on improving Auto Detection of Compilers
« Reply #6 on: January 22, 2012, 11:51:03 pm »
This is a completely safe patch to apply it fixes a few people issue on configuring CygWin automatically.

Tim S.

Code
Index: src/plugins/compilergcc/compilerCYGWIN.cpp
===================================================================
--- src/plugins/compilergcc/compilerCYGWIN.cpp (revision 7711)
+++ src/plugins/compilergcc/compilerCYGWIN.cpp (working copy)
@@ -35,9 +35,11 @@
 {
     CompilerMINGW::Reset();
 
-    m_Programs.C = _T("gcc.exe");
-    m_Programs.CPP = _T("g++.exe");
-    m_Programs.LD = _T("g++.exe");
+    // NOTE: Cygwin's gcc.exe is a file link and
+    // is not a good default name for running via cmd.exe
+    m_Programs.C = _T("gcc-3.exe");
+    m_Programs.CPP = _T("g++-3.exe");
+    m_Programs.LD = _T("g++-3.exe");
     m_Programs.DBG = _T("gdb.exe");
     m_Programs.LIB = _T("ar.exe");
     m_Programs.WINDRES = _T("windres.exe");
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: My research on improving Auto Detection of Compilers
« Reply #7 on: January 23, 2012, 01:48:38 pm »
This is my patch that requires minor SDK header file changes to enum type AutoDetectResult in Compiler.h.

Tim S.

Code
Index: src/plugins/compilergcc/compilerCYGWIN.cpp
===================================================================
--- src/plugins/compilergcc/compilerCYGWIN.cpp (revision 7711)
+++ src/plugins/compilergcc/compilerCYGWIN.cpp (working copy)
@@ -35,9 +35,11 @@
 {
     CompilerMINGW::Reset();
 
-    m_Programs.C = _T("gcc.exe");
-    m_Programs.CPP = _T("g++.exe");
-    m_Programs.LD = _T("g++.exe");
+    // NOTE: Cygwin's gcc.exe is a file link and
+    // is not a good default name for running via cmd.exe
+    m_Programs.C = _T("gcc-3.exe");
+    m_Programs.CPP = _T("g++-3.exe");
+    m_Programs.LD = _T("g++-3.exe");
     m_Programs.DBG = _T("gdb.exe");
     m_Programs.LIB = _T("ar.exe");
     m_Programs.WINDRES = _T("windres.exe");
@@ -48,24 +50,87 @@
     m_Options.AddOption(_("Do not use cygwin specific functionality"), _T("-mno-cygwin"), _("General"));
 }
 
+bool isNormalFileNotSymlink(const wxString& filename){
+    if (wxFileExists(filename)){
+        wxFile aFile(filename);
+        if (aFile.IsOpened()){
+            char buffer[10]={0};
+            aFile.Read(buffer,10);
+            if (memcmp("!<symlink>", buffer, 10) != 0){
+                return true;
+            }
+        }
+    }
+    return false;
+}
+
 AutoDetectResult CompilerCYGWIN::AutoDetectInstallationDir()
 {
-    m_MasterPath = _T("C:\\Cygwin"); // just a guess
+    AutoDetectResult ret = adrGuessed;
+    wxString tempMasterPath = _T("C:\\Cygwin"); // just a guess
+    m_MasterPath = tempMasterPath;
+    bool validInstallationDir = false;
 
     // look in registry for Cygwin
 
     wxRegKey key; // defaults to HKCR
-    key.SetName(_T("HKEY_LOCAL_MACHINE\\Software\\Cygnus Solutions\\Cygwin\\mounts v2\\/"));
+    key.SetName(_T("HKEY_LOCAL_MACHINE\\Software\\Cygwin\\setup"));
     if (key.Exists() && key.Open(wxRegKey::Read))
     {
-        // found; read it
-        key.QueryValue(_T("native"), m_MasterPath);
+        // found CygWin version 1.7 or newer; read it
+        key.QueryValue(_T("rootdir"), tempMasterPath);
+        if (wxDirExists(
+                tempMasterPath + wxFILE_SEP_PATH +
+                _T("bin"))
+        ){
+                validInstallationDir = true;
+        }
     }
-    AutoDetectResult ret = wxFileExists(m_MasterPath + wxFILE_SEP_PATH +
-                                        _T("bin") + wxFILE_SEP_PATH +
-                                        m_Programs.C)
-                            ? adrDetected
-                            : adrGuessed;
+    if (!validInstallationDir){
+        key.SetName(_T("HKEY_LOCAL_MACHINE\\Software\\Cygnus Solutions\\Cygwin\\mounts v2\\/"));
+        if (key.Exists() && key.Open(wxRegKey::Read))
+        {
+            // found CygWin version 1.5 or older; read it
+            key.QueryValue(_T("native"), tempMasterPath);
+            if (wxDirExists(
+                    tempMasterPath + wxFILE_SEP_PATH +
+                    _T("bin")
+                )
+            ){
+                validInstallationDir = true;
+            }
+        }
+    }
+
+    if (validInstallationDir){
+        wxString cProgramDir = tempMasterPath + wxFILE_SEP_PATH +
+            _T("bin") + wxFILE_SEP_PATH;
+        wxString cProgramFullname = cProgramDir + m_Programs.C;
+        if (isNormalFileNotSymlink(cProgramFullname)){
+            m_MasterPath = tempMasterPath;
+            ret = adrDetected;
+        } else {
+            if (isNormalFileNotSymlink(cProgramDir + _T("gcc-4.exe"))){
+                m_Programs.C = _T("gcc-4.exe");
+                m_Programs.CPP = _T("g++-4.exe");
+                m_Programs.LD = _T("g++-4.exe");
+                m_MasterPath = tempMasterPath;
+                ret = adrDetectedToolChain;
+            } else if (isNormalFileNotSymlink(cProgramDir + _T("gcc-3.exe"))){
+                m_Programs.C = _T("gcc-3.exe");
+                m_Programs.CPP = _T("g++-3.exe");
+                m_Programs.LD = _T("g++-3.exe");
+                m_MasterPath = tempMasterPath;
+                ret = adrDetectedToolChain;
+            }
+        }
+    }
+
+    if (validInstallationDir && ret == adrGuessed){
+        m_MasterPath = tempMasterPath;
+        ret = adrDetectedDir;
+    }
+
     return ret;
 }
 
Index: src/plugins/compilergcc/compileroptionsdlg.cpp
===================================================================
--- src/plugins/compilergcc/compileroptionsdlg.cpp (revision 7711)
+++ src/plugins/compilergcc/compileroptionsdlg.cpp (working copy)
@@ -1299,6 +1299,37 @@
 
     switch (compiler->AutoDetectInstallationDir())
     {
+        case adrDetectedDir:
+        {
+            wxString msg;
+            msg.Printf(_("Auto-detected \"%s\";but, failed to find a valid C-Compiler\nin installation path of \"%s\"\n"
+                         "Do you want to use this installation directory?"),
+                        #if wxCHECK_VERSION(2, 9, 0)
+                        compiler->GetName().wx_str(), compiler->GetMasterPath().wx_str());
+                        #else
+                        compiler->GetName().c_str(), compiler->GetMasterPath().c_str());
+                        #endif
+            if (cbMessageBox(msg, _("Confirmation"), wxICON_QUESTION | wxYES_NO) == wxID_NO)
+            {
+                compiler->SetMasterPath(backup);
+                compiler->SetExtraPaths(ExtraPathsBackup);
+            }
+        }
+        break;
+
+        case adrDetectedToolChain:
+        {
+            wxString msg;
+            #if wxCHECK_VERSION(2, 9, 0)
+            msg.Printf(_("Auto-detected \"%s\"\nwith different C-Compiler filename \nin installation path of \"%s\""), compiler->GetName().wx_str(), compiler->GetMasterPath().wx_str());
+            #else
+            msg.Printf(_("Auto-detected \"%s\"\nwith different C-Compiler filename \nin installation path of \"%s\""), compiler->GetName().c_str(), compiler->GetMasterPath().c_str());
+            #endif
+            cbMessageBox(msg);
+            DoFillCompilerPrograms();
+        }
+        break;
+
         case adrDetected:
         {
             wxString msg;
Index: src/include/compiler.h
===================================================================
--- src/include/compiler.h (revision 7711)
+++ src/include/compiler.h (working copy)
@@ -142,7 +142,9 @@
 enum AutoDetectResult
 {
     adrDetected,
-    adrGuessed
+    adrGuessed,
+    adrDetectedDir,
+    adrDetectedToolChain
 };
 
 /// Struct to keep programs
« Last Edit: January 23, 2012, 05:53:35 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: My research on improving Auto Detection of Compilers
« Reply #8 on: March 03, 2012, 08:45:48 pm »
Updated patch tested it some; but, I have a cold and not thinking well.

Tim S.

Code
Index: src/plugins/compilergcc/compilerCYGWIN.cpp
===================================================================
--- src/plugins/compilergcc/compilerCYGWIN.cpp (revision 7879)
+++ src/plugins/compilergcc/compilerCYGWIN.cpp (working copy)
@@ -51,6 +51,20 @@
     m_Options.AddOption(_("Do not use cygwin specific functionality"), _T("-mno-cygwin"), _("General"));
 }
 
+bool isNormalFileNotSymlink(const wxString& filename){
+    if (wxFileExists(filename)){
+        wxFile aFile(filename);
+        if (aFile.IsOpened()){
+            char buffer[10]={0};
+            aFile.Read(buffer,10);
+            if (memcmp("!<symlink>", buffer, 10) != 0){
+                return true;
+            }
+        }
+    }
+    return false;
+}
+
 AutoDetectResult CompilerCYGWIN::AutoDetectInstallationDir()
 {
     AutoDetectResult ret = adrGuessed;
@@ -81,24 +95,33 @@
         }
     }
 
-    if (!validInstallationDir)
-        return ret;
+    if (validInstallationDir){
+        wxString cProgramDir = tempMasterPath + wxFILE_SEP_PATH +
+            _T("bin") + wxFILE_SEP_PATH;
+        wxString cProgramFullname = cProgramDir + m_Programs.C;
+        if (isNormalFileNotSymlink(cProgramFullname)){
+            m_MasterPath = tempMasterPath;
+            ret = adrDetected;
+        } else {
+            if (isNormalFileNotSymlink(cProgramDir + _T("gcc-4.exe"))){
+                m_Programs.C = _T("gcc-4.exe");
+                m_Programs.CPP = _T("g++-4.exe");
+                m_Programs.LD = _T("g++-4.exe");
+                m_MasterPath = tempMasterPath;
+                ret = adrDetectedToolChain;
+            } else if (isNormalFileNotSymlink(cProgramDir + _T("gcc-3.exe"))){
+                m_Programs.C = _T("gcc-3.exe");
+                m_Programs.CPP = _T("g++-3.exe");
+                m_Programs.LD = _T("g++-3.exe");
+                m_MasterPath = tempMasterPath;
+                ret = adrDetectedToolChain;
+            }
+        }
+    }
 
-    wxString cProgramDir = tempMasterPath + wxFILE_SEP_PATH + _T("bin") + wxFILE_SEP_PATH;
-    wxString cProgramFullname = cProgramDir + m_Programs.C;
-    if ( !wxFileExists(cProgramFullname) )
-        return ret;
-
-    wxFile pfFile(cProgramFullname);
-    if ( !pfFile.IsOpened() )
-       return ret;
-
-    char buffer[10] = {0};
-    pfFile.Read(buffer,10);
-    if (memcmp("!<symlink>", buffer, 10) != 0)
-    {
+    if (validInstallationDir && ret == adrGuessed){
         m_MasterPath = tempMasterPath;
-        ret = adrDetected;
+        ret = adrDetectedDir;
     }
 
     return ret;
Index: src/plugins/compilergcc/compileroptionsdlg.cpp
===================================================================
--- src/plugins/compilergcc/compileroptionsdlg.cpp (revision 7879)
+++ src/plugins/compilergcc/compileroptionsdlg.cpp (working copy)
@@ -1299,6 +1299,37 @@
 
     switch (compiler->AutoDetectInstallationDir())
     {
+        case adrDetectedDir:
+        {
+            wxString msg;
+            msg.Printf(_("Auto-detected \"%s\";but, failed to find a valid C-Compiler\nin installation path of \"%s\"\n"
+                         "Do you want to use this installation directory?"),
+                        #if wxCHECK_VERSION(2, 9, 0)
+                        compiler->GetName().wx_str(), compiler->GetMasterPath().wx_str());
+                        #else
+                        compiler->GetName().c_str(), compiler->GetMasterPath().c_str());
+                        #endif
+            if (cbMessageBox(msg, _("Confirmation"), wxICON_QUESTION | wxYES_NO) == wxID_NO)
+            {
+                compiler->SetMasterPath(backup);
+                compiler->SetExtraPaths(ExtraPathsBackup);
+            }
+        }
+        break;
+
+        case adrDetectedToolChain:
+        {
+            wxString msg;
+            #if wxCHECK_VERSION(2, 9, 0)
+            msg.Printf(_("Auto-detected \"%s\"\nwith different C-Compiler filename \nin installation path of \"%s\""), compiler->GetName().wx_str(), compiler->GetMasterPath().wx_str());
+            #else
+            msg.Printf(_("Auto-detected \"%s\"\nwith different C-Compiler filename \nin installation path of \"%s\""), compiler->GetName().c_str(), compiler->GetMasterPath().c_str());
+            #endif
+            cbMessageBox(msg);
+            DoFillCompilerPrograms();
+        }
+        break;
+
         case adrDetected:
         {
             wxString msg;
Index: src/include/compiler.h
===================================================================
--- src/include/compiler.h (revision 7879)
+++ src/include/compiler.h (working copy)
@@ -142,7 +142,9 @@
 enum AutoDetectResult
 {
     adrDetected,
-    adrGuessed
+    adrGuessed,
+    adrDetectedDir,
+    adrDetectedToolChain
 };
 
 /// Struct to keep programs
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org