Author Topic: [C++] Compiling With CPP filename & co.  (Read 4061 times)

0 Members and 1 Guest are viewing this topic.

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
[C++] Compiling With CPP filename & co.
« on: October 15, 2009 »
Hiya,

As I make updates to versions of code in the same project / solution. I wondered rather than it keep overwritting the executable, is there a way to compile with a different filename, eg the one I am currently editting, for say "Fireworks 1-2.cpp" will generate "Fireworks 1-2.exe", and then if I do 1-3, that also makes "Fireworks 1-3.exe" ?

Also, whilst im on the keys, it's very confusing that I have multiple sets of Release And Debug folders within my projects. There's a set in the root directory, and then there's another set in "fireworks". is that normall?

Cheers and have a good one,
Clyde.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: [C++] Compiling With CPP filename & co.
« Reply #1 on: October 15, 2009 »
Quote
As I make updates to versions of code in the same project / solution. I wondered rather than it keep overwritting the executable, is there a way to compile with a different filename, eg the one I am currently editting, for say "Fireworks 1-2.cpp" will generate "Fireworks 1-2.exe", and then if I do 1-3, that also makes "Fireworks 1-3.exe"
There's no facility for doing that.  I'm not sure why you would want to.

Quote
it's very confusing that I have multiple sets of Release And Debug folders within my projects. There's a set in the root directory, and then there's another set in "fireworks". is that normall?
Not normal.  Some of them are left overs from your tinkering, there would usually only be one set.

Jim
Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: [C++] Compiling With CPP filename & co.
« Reply #2 on: October 15, 2009 »
you can specify it manuallly :
  project properties -> linker -> General -> Output File

By default this is set to "$(OutDir)\$(ProjectName).exe"
modfiy that to "$(OutDir)\YourNewExeName.exe"

It would be much quicker to just have your release folder open and rename the file itself. Than having to go through the options to rename it.


Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: [C++] Compiling With CPP filename & co.
« Reply #3 on: October 15, 2009 »
Quote
is there a way to compile with a different filename, eg the one I am currently editting, for say "Fireworks 1-2.cpp" will generate "Fireworks 1-2.exe", and then if I do 1-3, that also makes "Fireworks 1-3.exe" ?
Well, that's what for example FB-IDE was doing and probably appears feasible to you for your C-coding, too.
But this makes sense for this specific Basic-IDE only because there's just one "main" source file and no associated linking process.

In C/C++ things work a bit differently. You usually have a lot (and for big projects that's thousands) of source-files that can be compiled independently. The benefit is when you change only a single file, the compiler can just recompile this single file and leave the rest untouched (saving a couple of minutes of rebuilding-time).
In a second process the linker assembles all the code that is spread across many .obj-files (and probably a couple of libs) to a single .exe.
The linker can't know that you want it to name the resulting executable just like one of the source-files, that's why you have to specify the name manually.

More generally I don't think it's a good idea to have different versions of source-files inside a single project, or even have version numbers within the filename.
The reason why there's a "project" at all is to let the compiler know what needs to be compiled and let the linker know what needs to stuffed into your exe.
If you've got things floating around that doesn't belong to any of these two then it's simply garbage.
When you've reached a state you want to preserve better make a copy.

Managing sources and settings is one of the main virtues of C++ programming.
Besides laziness, impatience and hubris of course.
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: [C++] Compiling With CPP filename & co.
« Reply #4 on: October 15, 2009 »
Quote
Besides laziness, impatience and hubris of course.
Hey!  Those are some of my best qualities :P

Jim
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: [C++] Compiling With CPP filename & co.
« Reply #5 on: October 18, 2009 »
Thanks Hell Fire dude,

There's alot of habits I need to break; the simple solution if I need to is to rename the exe in windows explorer.

Not sure if im a hurbris.

Ah, before I go what would you tend to put into a header file, to clean up a tad a cpp file? And is that what they generally are, as some example projects I've seen look alot like a cpp. Sorry if this doesnt make alot of sense, hope you get the jist.

Thankyou,
Clyde.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: [C++] Compiling With CPP filename & co.
« Reply #6 on: October 18, 2009 »
Things that belong in include files are: constants, class definitions, enums, typedefs, structs, macros.  No code except inline methods in the classes.

If you want to get more tidy, make one include file for each class or concept (e.g. your sprite thing has a couple of related classes).  Make one cpp file for each class.  That way you'll find it easier to reuse classes in other projects.

Jim
Challenge Trophies Won: