#ifdef...#endif statements breaking other sub projects



  • I have a "packages" subproject that various other projects rely on to determine which packages they have access too.

    "packages" has an "enum Packages" which has various values that control which packages are available. I do this with #ifdef _sysID_ ...#endif satements around the groups of enum values under the enum definition. The projects ID is controlled by a DEFINES += _sysID_ statement inside a systemID.pri file that "packages" checks at compile time. This way all of our main projects can use the "packages" sub-project for package control, and can each set their own system ID which is check at compile time.

    I thought I was all sorts of clever with this, as "packages" compiled just fine, and in the project I tested it with, correctly detected the system ID to compile the correct enum values. The issue I'm running into is that, while I can compile "packages" just fine, the other components in the main project that are looking for the enum values are producing errors at compile time when I try to compile the whole project.

    The errors are "such-and-such is not a member of "packages"". Now, I have the ordered flag set, so I know the "packages" sub-project is compiling first. I've even tested this manually by building it, and then manually building part of the main project that relies on it, and I still get the same errors.

    Why are the other components of the project unaware of the enum values when "projects" has already compiled and has those values available?



  • Because of

    Controlled by a DEFINES += sysID statement inside a systemID.pri

    Since the sub-projects don't have access to this define they have no way of knowing.

    Enums are just copy-paste of values. They are not compiled into a binary form once you build the "packages" project.



  • I was concerned something like that would be the problem. Ok, a different approach is needed then. Thank you.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.