Author Topic: Bug: Relative file paths  (Read 9281 times)

Offline carra

  • Multiple posting newcomer
  • *
  • Posts: 114
Bug: Relative file paths
« on: June 18, 2012, 12:41:07 pm »
I don't want to clutter the nightly threads with this issue, so I'll give it it's own thread. This is the information I can give as of now:

- It happens when there is a header above the project's base folder.
- It causes object files to be created in the wrong folder, due to path concatenation
- The bug was introduced somewhere between builds 7966 (no bug) and 8024 (has the bug)

Attached you will find a minimal example project to reproduce the bug.
Thanks for your time!

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Bug: Relative file paths
« Reply #1 on: June 18, 2012, 07:46:05 pm »
As first this is not a bug !
The older revisions of C::B had a bug, that led to unusable projects, due to incorrect calculation of the projects common toplevel path. I fixed this in svn r7966, see http://forums.codeblocks.org/index.php/topic,16322.msg110516.html#msg110516 for details.

The output name of an object-file is created from the source file with the path relative to the common toplevel directory of the project, not relative to the project-file's folder.

This relative path is used to create the output below the configured objects output directory.
You can avoid this by checking "Settings -> Compiler... -> Global compiler settings -> [your compiler] -> Other settings -> Advanced options -> Others -> Use flat objects", but this will lead to problems, if two source-files have the same name (obviously).

What might be misleading, is that the object output dir is relative to the projects base path (the path, where the project-file is, and not to the projects common toplevel path.
But as the path can be added with the "..."-button it should not be a problem.

Nevertheless, there s another issue with object files:
if the common toplevel path changes after the project is opened (by adding new files e.g.), the objects output path does not get recalculated.

Offline carra

  • Multiple posting newcomer
  • *
  • Posts: 114
Re: Bug: Relative file paths
« Reply #2 on: June 18, 2012, 08:17:25 pm »
I see, so we are in the classic "it's not a bug, it's a feature!"  ;D
Well, I do not expect to have to have multiple files with the same name (not in the same project), so if it can be disabled through "use flat objects" option, that's ok.

Although I have to say that, even it being a fix for something worse, it was still quite unintuitive (user-wise) setting a project option for "output object folder" and have them appear at another folder.

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Bug: Relative file paths
« Reply #3 on: June 18, 2012, 08:36:57 pm »
Although I have to say that, even it being a fix for something worse, it was still quite unintuitive (user-wise) setting a project option for "output object folder" and have them appear at another folder.

In my test case, it appears exactly where it is set up, but it contains subfolders, that are build from the sources path relative to the projects common toplevel path.

Offline carra

  • Multiple posting newcomer
  • *
  • Posts: 114
Re: Bug: Relative file paths
« Reply #4 on: June 18, 2012, 09:38:46 pm »
In my test case, it appears exactly where it is set up, but it contains subfolders, that are build from the sources path relative to the projects common toplevel path.
Yes, that is what happens. Unrequested subfolders are created.
I know, not THAT big deal (since it doesn't prevent linking), but it was just annoying to not have them created where you expected them to be.