Search code examples
eclipseeclipse-cdt

Seemingly random numbers in Eclipse project files


Looking at Eclipse .cproject and .project files I see many seemingly random numbers:

<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.debug.928002373"
<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug.1473978281"
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1028037841" 
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.917558104"
 etc...

What are the numbers for?

I am writing a script that generates the files, and I am unsure if I need to change those numbers for each project I generate the files for - or they can stay the same?

Projects may be open in same workspace, so I am affraid of some kind of collisions.


Solution

  • They really are just random numbers.

    I traced the addition of the random part of the identifiers back to a commit in 2003, which references Eclipse bug 44020.

    That bug concerns a workspace with two projects, where the include paths of the projects get confused. The explanation provided is:

    The problem appears to have been caused by overlapping IDs in the build model. I have added code to make the IDs more unique and with a clean workspace, I can no longer get this behaviour to occur.

    So, it would seem that certain settings are grouped by some identifier (e.g. of a build configuration), and this can happen across projects in a given workspace – or at least that was the case in 2003. (The code is much too convoluted for me to assess whether that's still the case.)

    Anyways, to be on the safe side, I would make the IDs in the generated file unique across different projects in the workspace.


    That said, on the more general topic of writing a script to generate .cproject files, I would suggest reading this.