Skip to content

Commit

Permalink
Fix ambiguous build error of bridge app
Browse files Browse the repository at this point in the history
ComposedDevice has the same type and variable name, so an ambiguous
build error occurs as shown below. This change renames the variable to
gComposeDevice.

../../main.cpp: In function ‘void ApplicationInit()’:
../../main.cpp:924:5: error: reference to ‘ComposedDevice’ is ambiguous
  924 |     ComposedDevice.SetReachable(true);
      |     ^~~~~~~~~~~~~~
../../main.cpp:174:16: note: candidates are: ‘ComposedDevice {anonymous}::ComposedDevice’
  174 | ComposedDevice ComposedDevice("Composed Device", "Bedroom");
      |                ^~~~~~~~~~~~~~
In file included from ../../main.cpp:46:
../../include/Device.h:158:7: note:                 ‘class ComposedDevice’
  158 | class ComposedDevice : public Device
      |       ^~~~~~~~~~~~~~
../../main.cpp:954:24: error: reference to ‘ComposedDevice’ is ambiguous
  954 |     AddDeviceEndpoint(&ComposedDevice, &bridgedComposedDeviceEndpoint, Span<const EmberAfDeviceType>(gBridgedComposedDeviceTypes),
      |                        ^~~~~~~~~~~~~~
../../main.cpp:174:16: note: candidates are: ‘ComposedDevice {anonymous}::ComposedDevice’
  174 | ComposedDevice ComposedDevice("Composed Device", "Bedroom");
      |                ^~~~~~~~~~~~~~
In file included from ../../main.cpp:46:
../../include/Device.h:158:7: note:                 ‘class ComposedDevice’
  158 | class ComposedDevice : public Device
      |       ^~~~~~~~~~~~~~
../../main.cpp:958:76: error: reference to ‘ComposedDevice’ is ambiguous
  958 |                       Span<DataVersion>(gComposedTempSensor1DataVersions), ComposedDevice.GetEndpointId());
      |                                                                            ^~~~~~~~~~~~~~
../../main.cpp:174:16: note: candidates are: ‘ComposedDevice {anonymous}::ComposedDevice’
  174 | ComposedDevice ComposedDevice("Composed Device", "Bedroom");
      |                ^~~~~~~~~~~~~~
In file included from ../../main.cpp:46:
../../include/Device.h:158:7: note:                 ‘class ComposedDevice’
  158 | class ComposedDevice : public Device
      |       ^~~~~~~~~~~~~~
../../main.cpp:961:76: error: reference to ‘ComposedDevice’ is ambiguous
  961 |                       Span<DataVersion>(gComposedTempSensor2DataVersions), ComposedDevice.GetEndpointId());
      |                                                                            ^~~~~~~~~~~~~~
../../main.cpp:174:16: note: candidates are: ‘ComposedDevice {anonymous}::ComposedDevice’
  174 | ComposedDevice ComposedDevice("Composed Device", "Bedroom");
      |                ^~~~~~~~~~~~~~
In file included from ../../main.cpp:46:
../../include/Device.h:158:7: note:                 ‘class ComposedDevice’
  158 | class ComposedDevice : public Device
      |       ^~~~~~~~~~~~~~
../../main.cpp:977:28: error: reference to ‘ComposedDevice’ is ambiguous
  977 |     endpointList.push_back(ComposedDevice.GetEndpointId());
      |                            ^~~~~~~~~~~~~~
../../main.cpp:174:16: note: candidates are: ‘ComposedDevice {anonymous}::ComposedDevice’
  174 | ComposedDevice ComposedDevice("Composed Device", "Bedroom");
      |                ^~~~~~~~~~~~~~
In file included from ../../main.cpp:46:
../../include/Device.h:158:7: note:                 ‘class ComposedDevice’
  158 | class ComposedDevice : public Device
      |       ^~~~~~~~~~~~~~
../../main.cpp:981:39: error: reference to ‘ComposedDevice’ is ambiguous
  981 |     ComposedPowerSource.SetEndpointId(ComposedDevice.GetEndpointId());
      |                                       ^~~~~~~~~~~~~~
../../main.cpp:174:16: note: candidates are: ‘ComposedDevice {anonymous}::ComposedDevice’
  174 | ComposedDevice ComposedDevice("Composed Device", "Bedroom");
      |                ^~~~~~~~~~~~~~
In file included from ../../main.cpp:46:
../../include/Device.h:158:7: note:                 ‘class ComposedDevice’
  158 | class ComposedDevice : public Device
      |       ^~~~~~~~~~~~~~
At global scope:
cc1plus: error: unrecognized command line option ‘-Wno-unknown-warning-option’ [-Werror]
cc1plus: all warnings being treated as errors
ninja: build stopped: subcommand failed.

Signed-off-by: Youngho Yoon <[email protected]>
  • Loading branch information
yhoyoon committed Jul 25, 2024
1 parent 8ab7299 commit 8d79c14
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions examples/bridge-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ DeviceOnOff ActionLight3("Action Light 3", "Room 2");
DeviceOnOff ActionLight4("Action Light 4", "Room 2");

// Setup composed device with two temperature sensors and a power source
ComposedDevice ComposedDevice("Composed Device", "Bedroom");
ComposedDevice gComposedDevice("Composed Device", "Bedroom");
DeviceTempSensor ComposedTempSensor1("Composed TempSensor 1", "Bedroom", minMeasuredValue, maxMeasuredValue, initialMeasuredValue);
DeviceTempSensor ComposedTempSensor2("Composed TempSensor 2", "Bedroom", minMeasuredValue, maxMeasuredValue, initialMeasuredValue);
DevicePowerSource ComposedPowerSource("Composed Power Source", "Bedroom", PowerSource::Feature::kBattery);
Expand Down Expand Up @@ -921,7 +921,7 @@ void ApplicationInit()
ActionLight3.SetChangeCallback(&HandleDeviceOnOffStatusChanged);
ActionLight4.SetChangeCallback(&HandleDeviceOnOffStatusChanged);

ComposedDevice.SetReachable(true);
gComposedDevice.SetReachable(true);
ComposedTempSensor1.SetReachable(true);
ComposedTempSensor2.SetReachable(true);
ComposedPowerSource.SetReachable(true);
Expand Down Expand Up @@ -951,14 +951,14 @@ void ApplicationInit()
Span<DataVersion>(gTempSensor2DataVersions), 1);

// Add composed Device with two temperature sensors and a power source
AddDeviceEndpoint(&ComposedDevice, &bridgedComposedDeviceEndpoint, Span<const EmberAfDeviceType>(gBridgedComposedDeviceTypes),
AddDeviceEndpoint(&gComposedDevice, &bridgedComposedDeviceEndpoint, Span<const EmberAfDeviceType>(gBridgedComposedDeviceTypes),
Span<DataVersion>(gComposedDeviceDataVersions), 1);
AddDeviceEndpoint(&ComposedTempSensor1, &bridgedTempSensorEndpoint,
Span<const EmberAfDeviceType>(gComposedTempSensorDeviceTypes),
Span<DataVersion>(gComposedTempSensor1DataVersions), ComposedDevice.GetEndpointId());
Span<DataVersion>(gComposedTempSensor1DataVersions), gComposedDevice.GetEndpointId());
AddDeviceEndpoint(&ComposedTempSensor2, &bridgedTempSensorEndpoint,
Span<const EmberAfDeviceType>(gComposedTempSensorDeviceTypes),
Span<DataVersion>(gComposedTempSensor2DataVersions), ComposedDevice.GetEndpointId());
Span<DataVersion>(gComposedTempSensor2DataVersions), gComposedDevice.GetEndpointId());

// Add 4 lights for the Action Clusters tests
AddDeviceEndpoint(&ActionLight1, &bridgedLightEndpoint, Span<const EmberAfDeviceType>(gBridgedOnOffDeviceTypes),
Expand All @@ -974,11 +974,11 @@ void ApplicationInit()
gDevices[CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT] = &ComposedPowerSource;
// This provides power for the composed endpoint
std::vector<chip::EndpointId> endpointList;
endpointList.push_back(ComposedDevice.GetEndpointId());
endpointList.push_back(gComposedDevice.GetEndpointId());
endpointList.push_back(ComposedTempSensor1.GetEndpointId());
endpointList.push_back(ComposedTempSensor2.GetEndpointId());
ComposedPowerSource.SetEndpointList(endpointList);
ComposedPowerSource.SetEndpointId(ComposedDevice.GetEndpointId());
ComposedPowerSource.SetEndpointId(gComposedDevice.GetEndpointId());

gRooms.push_back(&room1);
gRooms.push_back(&room2);
Expand Down

0 comments on commit 8d79c14

Please sign in to comment.