Author Topic: when does a project file get updated?  (Read 6769 times)

brd24

  • Guest
when does a project file get updated?
« on: July 21, 2013, 11:58:35 am »
I searched google, but I couldn't fined the answer, so I'll ask here.

I updated my main.c file in my project, and ran the project from the command line.
I tried the following things, but only the last one resulted in a change in the executable file:
1. save main.c
2. save the project
3. compile main.c
4. press F9 and run the project from code::blocks (not the command line)

I understand if I hadn't saved main.c, no change would be reflected.
I also (think) I understand that simply saving the project does not create any object files, so the exe file would stay the same, although I am unsure about this one.
But I do not understand why compiling main.c and therefore creating the object file failed to update the executable file.

Another related question is why when I save project, the files themselves did not get saved.
After changing main.c, and saving the project, the asterisk at the tab of main.c indicates the file is unsaved.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: when does a project file get updated?
« Reply #1 on: July 21, 2013, 03:23:50 pm »
Can you give us a detailed steps? I'm not quite understand your question.

Quote
ran the project from the command line
What is "run the project" means?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline blauzahn

  • Almost regular
  • **
  • Posts: 180
Re: when does a project file get updated?
« Reply #2 on: July 21, 2013, 04:46:09 pm »

Code::Blocks gives you the choice.

1, 2 and 3 do what they pretend to do. Nothing more, nothing less.
That is, if you compile main.c cb will ask the compiler to produce a main.o
but does not call the linker.

In addition to these commands you can always use the combined ones
("save all files", "save everything", "build", "build and run" etc.).

I consider this behaviour actually a feature.

To distinguish between them is helpful, especially in larger projects:

* If you have temporarily set program arguments in your project, and
  want to build and run the  program several times, but do not want
  the arguments to be saved in the  project-file permanently. You often
  do not want your version-control (eg. mercurial, git) to commit
  these temporary things as changes to the project.
 
* If you just want to see, whether the edited file still compiles (quick) without
  being forced to call the linker as well (may take significantly more time).
 
* Run the existing executable (from previous build) to reverify the current
  behaviour before you acually compile and link the changed program.

If you have made changes to the project and are closing it you will be prompted
whether you want to save the changes.

All in all: A Project file gets updated when you tell cb to do so.