Author Topic: Using different MSVC compiler versions for same C::B target  (Read 6259 times)

Offline cacb

  • Lives here!
  • ****
  • Posts: 539
Using different MSVC compiler versions for same C::B target
« on: March 16, 2011, 11:39:07 am »
Hi,

One of the really excellent features of Code::Blocks is the use of global variables to handle different compiler paths, library paths etc.

I have C::B projects using MSVC compiler on Windows. I have VC2008 installed. When I investigate the C::B project files I find the following in my Windows build targets
Code
<Option compiler="msvc8" />

However, a friend wants to build the same code using his installed VC2010 compiler. The only way we got it to work was by performing a text search/replace to
Code
<Option compiler="msvc10" />

Then all is well, except we cannot share project files (I am not going to upgrade my compiler, for various reasons).

Is there some way we can improve this, for example using global variables? We tried this
Code
<Option compiler="$(#CPDE_COMPILER)" />

Hoping that CPDE_COMPILER would be understood as a global variable that we could set to msvc8 and msvc10 respectively. But it seems global variables are not recognised in this context?

We also tried removing the option completely (assuming our default compilers would be used), but that didn't work either.

Any Ideas how to handle this?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Using different MSVC compiler versions for same C::B target
« Reply #1 on: March 16, 2011, 12:53:03 pm »
Two solutions:
1. you duplicate the target, so your project has vc9 and vc10 targets
2. use commonly named compiler -> msvc for example...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline cacb

  • Lives here!
  • ****
  • Posts: 539
Re: Using different MSVC compiler versions for same C::B target
« Reply #2 on: March 16, 2011, 02:09:02 pm »
Two solutions:
1. you duplicate the target, so your project has vc9 and vc10 targets
2. use commonly named compiler -> msvc for example...

Interesting.
Solution 1 is not acceptable, as it doubles the amount of project maintenance.

Solution 2 seems like the way to go, but I need some more details on exactly how to do it. Do you mean that we both edit our default.conf files so that we get a generically named msvc compiler instead of a specific one?
msvc8 => msvc
msvc10 => msvc

If there is no caveats here, it seems like a general enough solution!

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Using different MSVC compiler versions for same C::B target
« Reply #3 on: March 16, 2011, 02:26:15 pm »
Solution 2 seems like the way to go, but I need some more details on exactly how to do it. Do you mean that we both edit our default.conf files so that we get a generically named msvc compiler instead of a specific one?
msvc8 => msvc
msvc10 => msvc

If there is no caveats here, it seems like a general enough solution!

Just copy the used compiler to a new one named "MSVC" in "Settings -> Compiler and debugger -> General compiler settings" on both systems.
In default.conf they will be called msvc in both cases.
So it should work without hacking default.conf directly.

Offline cacb

  • Lives here!
  • ****
  • Posts: 539
Re: Using different MSVC compiler versions for same C::B target
« Reply #4 on: March 16, 2011, 03:00:46 pm »
Just copy the used compiler to a new one named "MSVC" in "Settings -> Compiler and debugger -> General compiler settings" on both systems.
In default.conf they will be called msvc in both cases.
So it should work without hacking default.conf directly.

Thank you! That seems to work!  :D