Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Disambiguation of Same Name Classes
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Disambiguation of Same Name Classes

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 494 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DRoscoe
    wrote on last edited by DRoscoe
    #1

    I have a static library, aop_data that depends on another static library: DataCollection. The DataCollection library defines a namespace: cto4_data and in this namespace is a class named "State" The aop_data library also defines a class named "State" which is not scoped within a namespace. The problem I am having is that my Qt project is failing because its trying to use the wrong "State" class even though I am not explicitly specifying the cto4_data namespace AND I am including only the aop_data header for the State class in the class that is causing the problem:

    ../../../core/aop_data/hazards/AdsbTrajectoryChangeList.cpp:633:55: error: no member named 'getAltitude' in 'cto4_data::State'
    double altitude_delta = tcp.getAltitude() - state.getAltitude().getFeet();

    ~~~~~ ^
    ../../../core/aop_data/hazards/AdsbTrajectoryChangeList.cpp:636:44: error: no member named 'getAltitude' in 'cto4_data::State'
    TCR_DEBUG(2, "altitude is " << state.getAltitude() <<

    [...]

    There really should be no confusion about which version of "State" I am trying to use.

    I am asking this question here because this same situation exists in my non-Qt project, but MSVC++ does not complain about it. It's only my Qt project that is having this problem.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DRoscoe
      wrote on last edited by
      #2

      Turns out I was being too lazy with my INCLUDEPATH definitions. I was including .pri files which essentially declared library dependencies, which also specified include paths for that library. In most cases, all I really wanted were the include paths, but by putting the library dependencies in as well, I had to avoid circular dependencies which meant that the include path for cto4_data::State was defined before the include path for aop_data, so lines like #include "State.hpp" were bringing in the wrong class definition.

      The solution is to separate the INCLUDEPATH definitions from the library definitions, so they may be included independently from build order.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved