News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Patch for wizard's default compiler error

Started by Loaden, March 23, 2010, 05:21:38 AM

Previous topic - Next topic

Loaden

I have TWO compilers for CB, the default compiler is MinGW(gcc), and another is MSVC.

Now, When I create new MSVC8 projects, and debug CB, when step to this code:
void NativeParser::AddCompilerDirs(cbProject* project)
In the project directory will create a project file, which reads:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>

 <Option title="" />
 <Option pch_mode="2" />

 <Option compiler="gcc" />
 <Build />
 <Extensions>
  <code_completion />
  <debugger />
 </Extensions>
</Project>
</CodeBlocks_project_file>

We can see this line:  <Option compiler="gcc" />
It's must be msvc8, but NOT gcc!

So, I make a patch to fix this BUG.
Like this:
CompileTargetBase* Wiz::RunProjectWizard(wxString* pFilename)
{
...
   // now create the project
+    wxString defCompilerID = CompilerFactory::GetDefaultCompilerID();
+    CompilerFactory::SetDefaultCompiler(GetCompilerID());
   theproject = Manager::Get()->GetProjectManager()->NewProject(prjname);
+    CompilerFactory::SetDefaultCompiler(defCompilerID);
   if (!theproject)
   {
       cbMessageBox(_("Couldn't create the new project:\n") + prjdir, _("Error"), wxICON_ERROR);
       Clear();
       return 0;
   }


This patch only add three statements.
Now, it's work well.

Patch in here:
Index: src/plugins/scriptedwizard/wiz.cpp
===================================================================
--- src/plugins/scriptedwizard/wiz.cpp (revision 6195)
+++ src/plugins/scriptedwizard/wiz.cpp (working copy)
@@ -346,7 +346,10 @@
     }

     // now create the project
+    wxString defCompilerID = CompilerFactory::GetDefaultCompilerID();
+    CompilerFactory::SetDefaultCompiler(GetCompilerID());
     theproject = Manager::Get()->GetProjectManager()->NewProject(prjname);
+    CompilerFactory::SetDefaultCompiler(defCompilerID);
     if (!theproject)
     {
         cbMessageBox(_("Couldn't create the new project:\n") + prjdir, _("Error"), wxICON_ERROR);


[attachment deleted by admin]

killerbot

why do you do twice a 'CompilerFactory::SetDefaultCompiler' ?

MortenMacFly

Quote from: killerbot on March 23, 2010, 07:44:21 AM
why do you do twice a 'CompilerFactory::SetDefaultCompiler' ?
One time for setting the right compiler and one time for setting the old default compiler. This is correct. But I must admit that it looked weired to me in the first place, too.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

killerbot