Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several fixes to be compatible with gcc13 #107

Open
aurelien-enchanted-tools opened this issue Jul 15, 2024 · 1 comment
Open

Several fixes to be compatible with gcc13 #107

aurelien-enchanted-tools opened this issue Jul 15, 2024 · 1 comment

Comments

@aurelien-enchanted-tools

Hello,

branch main 1.10.8 1842cc7

I share with you these following fixes to be compatible with gcc13:

diff --git a/examples/c/Sample-DepthWorkMode/depth_work_mode.cpp b/examples/c/Sample-DepthWorkMode/depth_work_mode.cpp
index c5932ad..e7e1a0d 100644
--- a/examples/c/Sample-DepthWorkMode/depth_work_mode.cpp
+++ b/examples/c/Sample-DepthWorkMode/depth_work_mode.cpp
@@ -34,7 +34,7 @@ static char *toHexText(const uint8_t *data, const uint32_t dataLen) {
     return hexStr;
 }

-int main(int argc, char **argv) {
+int main() {

     // Print the sdk version number
     printf("SDK version: %d.%d.%d\n", ob_get_major_version(), ob_get_minor_version(), ob_get_patch_version());
@@ -70,7 +70,6 @@ int main(int argc, char **argv) {
     uint32_t mode_count = ob_depth_work_mode_list_count(mode_list, &error);
     printf("Support depth work mode list count: %u\n", mode_count);

-    int cur_mode_index = -1;
     for(uint32_t i = 0; i < mode_count; i++) {
         ob_depth_work_mode mode = ob_depth_work_mode_list_get_item(mode_list, i, &error);
         check_error(error);
@@ -84,9 +83,9 @@ int main(int argc, char **argv) {
         printf("\n");
     }

-    int mode_index;
+    uint32_t mode_index;
     printf("Please select a work mode index:");
-    scanf("%d", &mode_index);
+    (void) scanf("%d", &mode_index);
     if(mode_index >= 0 && mode_index < mode_count) {
         ob_depth_work_mode mode = ob_depth_work_mode_list_get_item(mode_list, mode_index, &error);
         check_error(error);
diff --git a/examples/c/Sample-FirmwareUpgrade/firmware_upgrade.cpp b/examples/c/Sample-FirmwareUpgrade/firmware_upgrade.cpp
index d2f87e9..6c1bc93 100644
--- a/examples/c/Sample-FirmwareUpgrade/firmware_upgrade.cpp
+++ b/examples/c/Sample-FirmwareUpgrade/firmware_upgrade.cpp
@@ -30,7 +30,6 @@ int                     callback_user_data_ = 0;
 static const char *check_firmware_file_path(int argc, char **argv);
 static void        dump_device_info(ob_device *device);
 static bool        upgrade_firmware(ob_device *device, const char *firmware_path);
-static uint64_t    get_current_time_ms();
 static void        device_changed_callback(ob_device_list *removed, ob_device_list *added, void *user_data);
 static void        device_upgrade_callback(ob_upgrade_state state, const char *message, uint8_t percent, void *user_data);

@@ -239,10 +239,6 @@ const char *check_firmware_file_path(int argc, char **argv) {
     return filePath;
 }

-uint64_t get_current_time_ms() {
-    auto now = std::chrono::system_clock::now();
-    return std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count();
-}

 bool upgrade_firmware(ob_device *device, const char *firmwarePath) {
     const char *index     = strstr(firmwarePath, ".img");
@@ -263,6 +263,7 @@ bool upgrade_firmware(ob_device *device, const char *firmwarePath) {
 }

 // Process firmware callback event
+#pragma GCC diagnostic warning "-Wuninitialized"
 void device_upgrade_callback(ob_upgrade_state state, const char *message, uint8_t percent, void *user_data) {
     if(state == STAT_START) {
         printf("Upgrade Firmware start\n");
@@ -286,6 +287,7 @@ void device_upgrade_callback(ob_upgrade_state state, const char *message, uint8_
 }

 // Process device change callback event
+#pragma GCC diagnostic warning "-Wuninitialized"
 void device_changed_callback(ob_device_list *removed, ob_device_list *added, void *user_data) {
     // Wait device attache and detach event after device upgrade firmware completed and call reboot.
     ob_error *error = NULL;
@@ -349,4 +351,4 @@ void device_changed_callback(ob_device_list *removed, ob_device_list *added, voi
     // destroy device list
     ob_delete_device_list(added, &error);
     check_error(error);
-}
\ No newline at end of file
+}
diff --git a/examples/c/Sample-HelloOrbbec/hello_orbbec.c b/examples/c/Sample-HelloOrbbec/hello_orbbec.c
index 2dd3394..4dd9574 100644
--- a/examples/c/Sample-HelloOrbbec/hello_orbbec.c
+++ b/examples/c/Sample-HelloOrbbec/hello_orbbec.c
@@ -18,7 +18,7 @@ void check_error(ob_error *error) {
     }
 }

-int main(int argc, char **argv) {
+int main() {

     // print sdk version number
     printf("SDK version: %d.%d.%d\n", ob_get_major_version(), ob_get_minor_version(), ob_get_patch_version());
@@ -148,4 +148,4 @@ int main(int argc, char **argv) {
     check_error(error);

     return 0;
-}
\ No newline at end of file
+}
diff --git a/examples/c/Sample-HotPlugin/hot_plugin.cpp b/examples/c/Sample-HotPlugin/hot_plugin.cpp
index 18f5da7..1ae7778 100644
--- a/examples/c/Sample-HotPlugin/hot_plugin.cpp
+++ b/examples/c/Sample-HotPlugin/hot_plugin.cpp
@@ -65,7 +65,7 @@ void        print_device_info(ob_device_info *device_info);  // print without ne
 void        print_depth_frame(ob_frame *frame);              // print without new line
 void        print_video_frame(ob_frame *frame);              // print without new line

-int main(int argc, char **argv) {
+int main() {
     ob_error *error = NULL;

     // create context
@@ -121,6 +121,7 @@ int main(int argc, char **argv) {
 }

 // Device state change callback
+#pragma GCC diagnostic warning "-Wuninitialized"
 void on_device_changed_callback(ob_device_list *removed, ob_device_list *added, void *user_data) {
     handle_device_disconnected(removed);
     handle_device_connected(added);
@@ -232,6 +233,7 @@ void stop_stream(std::shared_ptr<pipeline_holder> holder) {
     error = NULL;
 }

+#pragma GCC diagnostic warning "-Wuninitialized"
 void sample_frame_set_callback(ob_frame *frameset, void *user_data) {
     ob_error *error = NULL;

diff --git a/examples/c/Sample-SensorControl/sensor_control.c b/examples/c/Sample-SensorControl/sensor_control.c
index c8e7451..74935c3 100644
--- a/examples/c/Sample-SensorControl/sensor_control.c
+++ b/examples/c/Sample-SensorControl/sensor_control.c
@@ -35,7 +35,7 @@ const char *permissionTypeToString(ob_permission_type permission) {
     return "_/_";
 }

-int main(int argc, char **argv) {
+int main() {
     // Create a Context.
     ob_context *ctx = ob_create_context(&g_error);
     check_error(g_error);
@@ -85,8 +85,8 @@ int main(int argc, char **argv) {
         int               isSelectProperty   = 1;
         while(isSelectProperty) {
             char str[100] = { 0 };
-            // fgets(str,100, stdin);
-            gets(str);
+            fgets(str,100, stdin);
+            // gets(str);

             int  selectId     = 0;
             char setValue[20] = { 0 };
@@ -203,11 +203,11 @@ ob_device *select_device(ob_device_list *device_list) {
     printf("Select a device: ");

     int dev_index;
-    scanf("%d", &dev_index);
+    (void) scanf("%d", &dev_index);

     while(dev_index < 0 || dev_index >= dev_count) {
         printf("Your select is out of range, please reselect: \n");
-        scanf("%d", &dev_index);
+        (void) scanf("%d", &dev_index);
     }

     ob_device *device = ob_device_list_get_device(device_list, dev_index, &g_error);
@@ -230,7 +230,6 @@ void printf_property_list(ob_device *device, ob_property_item *property_list, in

         ob_int_property_range   int_range;
         ob_float_property_range float_range;
-        ob_bool_property_range  bool_range;
         switch(property_item.type) {
         case OB_BOOL_PROPERTY:
             sprintf(str, "Bool value(min:0, max:1, step:1)");
@@ -245,6 +244,7 @@ void printf_property_list(ob_device *device, ob_property_item *property_list, in
             check_control_property_error(g_error);
             sprintf(str, "Float value(min:%f, max:%f, step:%f,)", float_range.min, float_range.max, float_range.step);
             break;
+        case OB_STRUCT_PROPERTY:
         default:
             break;
         }
@@ -258,7 +258,7 @@ void printf_property_list(ob_device *device, ob_property_item *property_list, in
 void get_property_list(ob_device *device, ob_property_item **property_list, int *size) {
     uint32_t propertySize = ob_device_get_supported_property_count(device, &g_error);
     check_error(g_error);
-    int i     = 0;
+    uint32_t i = 0;
     int index = 0;
     for(i = 0; i < propertySize; i++) {
         ob_property_item property_item = ob_device_get_supported_property(device, i, &g_error);
@@ -323,6 +323,7 @@ void get_property_value(ob_device *device, ob_property_item property_item) {
         check_control_property_error();
         printf("property name:%s,get bool value:%f\n", property_item.name, float_ret);
         break;
+    case OB_STRUCT_PROPERTY:
     }
 }

diff --git a/examples/cpp/Sample-DepthWorkMode/DepthWorkMode.cpp b/examples/cpp/Sample-DepthWorkMode/DepthWorkMode.cpp
index e1ecf9a..97a8f46 100644
--- a/examples/cpp/Sample-DepthWorkMode/DepthWorkMode.cpp
+++ b/examples/cpp/Sample-DepthWorkMode/DepthWorkMode.cpp
@@ -23,7 +23,7 @@ static void pressKeyExit(std::string msg) {
 static std::string   toHexText(const uint8_t *data, const uint32_t dataLen);
 static std::ostream &operator<<(std::ostream &os, const OBDepthWorkMode &dataType);

-int main(int argc, char *argv[]) try {
+int main() try {
     // Print the sdk version number, the sdk version number is divided into major version number, minor version number and revision number
     std::cout << "SDK version: " << ob::Version::getMajor() << "." << ob::Version::getMinor() << "." << ob::Version::getPatch() << std::endl;

@@ -57,7 +57,7 @@ int main(int argc, char *argv[]) try {
         uint32_t index = 0;
         std::cout << "Please input the index from above depthModeList, newIndex = ";
         std::cin >> index;
-        if(index >= 0 && index < depthModeList->count()) {  // legitimacy check
+        if(index < depthModeList->count()) {  // legitimacy check
             device->switchDepthWorkMode((*depthModeList)[index].name);

             // Check whether the mode changes after the display is switched
@@ -105,4 +105,4 @@ static std::string toHexText(const uint8_t *data, const uint32_t dataLen) {
 static std::ostream &operator<<(std::ostream &os, const OBDepthWorkMode &workMode) {
     os << "{name: " << workMode.name << ", checksum: " << toHexText(workMode.checksum, sizeof(workMode.checksum)) << "}";
     return os;
-}
\ No newline at end of file
+}
diff --git a/examples/cpp/Sample-FirmwareUpgrade/FirmwareUpgrade.cpp b/examples/cpp/Sample-FirmwareUpgrade/FirmwareUpgrade.cpp
index 1f2ef48..8ead23d 100644
--- a/examples/cpp/Sample-FirmwareUpgrade/FirmwareUpgrade.cpp
+++ b/examples/cpp/Sample-FirmwareUpgrade/FirmwareUpgrade.cpp
@@ -26,7 +26,6 @@ std::shared_ptr<ob::Device> rebootedDevice_;
 static std::string checkFirmwareFilePath(int argc, char **argv);
 static void        dumpDeviceInfo(std::shared_ptr<ob::Device> device);
 static bool        upgradeFirmware(std::shared_ptr<ob::Device> device, std::string firmwarePath);
-static uint64_t    getCurrentTimeMs();

 int main(int argc, char **argv) try {
     std::string firmwareFilePath = checkFirmwareFilePath(argc, argv);
@@ -199,10 +199,6 @@ std::string checkFirmwareFilePath(int argc, char **argv) {
     return filePath;
 }

-uint64_t getCurrentTimeMs() {
-    auto now = std::chrono::system_clock::now();
-    return std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count();
-}

 bool upgradeFirmware(std::shared_ptr<ob::Device> device, std::string firmwarePath) {
     auto index     = firmwarePath.find_last_of(".img");
@@ -255,4 +255,4 @@ bool upgradeFirmware(std::shared_ptr<ob::Device> device, std::string firmwarePat
     }

     return isUpgradeSuccess;
-}
\ No newline at end of file
+}
diff --git a/examples/cpp/Sample-HelloOrbbec/HelloOrbbec.cpp b/examples/cpp/Sample-HelloOrbbec/HelloOrbbec.cpp
index 1f1f0f0..5e22575 100644
--- a/examples/cpp/Sample-HelloOrbbec/HelloOrbbec.cpp
+++ b/examples/cpp/Sample-HelloOrbbec/HelloOrbbec.cpp
@@ -5,7 +5,7 @@

 #define ESC 27

-int main(int argc, char **argv) try {
+int main() try {
     // Print the sdk version number, the sdk version number is divided into major version number, minor version number and revision number
     std::cout << "SDK version: " << ob::Version::getMajor() << "." << ob::Version::getMinor() << "." << ob::Version::getPatch() << std::endl;
     // Print sdk stage version
@@ -94,4 +94,4 @@ int main(int argc, char **argv) try {
 catch(ob::Error &e) {
     std::cerr << "function:" << e.getName() << "\nargs:" << e.getArgs() << "\nmessage:" << e.getMessage() << "\ntype:" << e.getExceptionType() << std::endl;
     exit(EXIT_FAILURE);
-}
\ No newline at end of file
+}
diff --git a/examples/cpp/Sample-HotPlugin/HotPlugin.cpp b/examples/cpp/Sample-HotPlugin/HotPlugin.cpp
index 3997e1c..05e5aac 100644
--- a/examples/cpp/Sample-HotPlugin/HotPlugin.cpp
+++ b/examples/cpp/Sample-HotPlugin/HotPlugin.cpp
@@ -40,7 +40,7 @@ void rebootDevices();
 void startStream(std::shared_ptr<PipelineHolder> holder);
 void stopStream(std::shared_ptr<PipelineHolder> holder);

-int main(int argc, char **argv) try {
+int main() try {

     // create context
     ob::Context ctx;
@@ -286,4 +286,4 @@ std::ostream &operator<<(std::ostream &os, std::shared_ptr<ob::VideoFrame> frame
     os << "FrameType: " << frame->type() << ", index: " << frame->index() << ", width: " << frame->width() << ", height: " << frame->height()
        << ", format: " << frame->format() << ", timeStampUs: " << frame->timeStampUs() << "us";
     return os;
-}
\ No newline at end of file
+}
diff --git a/examples/cpp/Sample-ImuReader/ImuReader.cpp b/examples/cpp/Sample-ImuReader/ImuReader.cpp
index fa3d938..9012779 100644
--- a/examples/cpp/Sample-ImuReader/ImuReader.cpp
+++ b/examples/cpp/Sample-ImuReader/ImuReader.cpp
@@ -5,7 +5,7 @@

 #define ESC 27
 std::mutex printerMutex;
-int        main(int argc, char **argv) try {
+int        main() try {
     // Print the SDK version number, the SDK version number is divided into major version number, minor version number and revision number
     std::cout << "SDK version: " << ob::Version::getMajor() << "." << ob::Version::getMinor() << "." << ob::Version::getPatch() << std::endl;

@@ -114,4 +114,4 @@ int        main(int argc, char **argv) try {
 catch(ob::Error &e) {
     std::cerr << "function:" << e.getName() << "\nargs:" << e.getArgs() << "\nmessage:" << e.getMessage() << "\ntype:" << e.getExceptionType() << std::endl;
     exit(EXIT_FAILURE);
-}
\ No newline at end of file
+}
diff --git a/examples/cpp/Sample-SensorControl/SensorControl.cpp b/examples/cpp/Sample-SensorControl/SensorControl.cpp
index 1344e82..83fe80a 100644
--- a/examples/cpp/Sample-SensorControl/SensorControl.cpp
+++ b/examples/cpp/Sample-SensorControl/SensorControl.cpp
@@ -17,7 +17,7 @@ void                        setPropertyValue(std::shared_ptr<ob::Device> device,
 void                        getPropertyValue(std::shared_ptr<ob::Device> device, OBPropertyItem item);
 std::string                 permissionTypeToString(OBPermissionType permission);

-int main(int argc, char **argv) try {
+int main() try {
     // Create a Context.
     ob::Context context;

@@ -118,7 +118,7 @@ std::shared_ptr<ob::Device> selectDevice(std::shared_ptr<ob::DeviceList> deviceL
     int devCount = deviceList->deviceCount();
     std::cout << "Device list: " << std::endl;
     for(int i = 0; i < devCount; i++) {
-        std::cout << i << ". name: " << deviceList->name(i) << ", vid: 0x" << std::hex << deviceList->vid(i) << ", pid: 0x" << std::setw(4) << std::setfill('0')
+        std::cout << i << ". vid: 0x" << std::hex << deviceList->vid(i) << ", pid: 0x" << std::setw(4) << std::setfill('0')
                   << deviceList->pid(i) << ", uid: 0x" << deviceList->uid(i) << ", sn: " << deviceList->serialNumber(i) << std::dec << std::endl;
     }
     std::cout << "Select a device: ";
@@ -142,7 +142,7 @@ void printfPropertyList(std::shared_ptr<ob::Device> device, const std::vector<OB
         std::cout << "No supported property!" << std::endl;
     }
     std::cout << "\n------------------------------------------------------------------------\n";
-    for(int i = 0; i < propertyList.size(); i++) {
+    for(long unsigned int i = 0; i < propertyList.size(); i++) {
         auto        property_item = propertyList[i];
         std::string strRange      = "";

@@ -307,4 +307,4 @@ std::string permissionTypeToString(OBPermissionType permission) {
         break;
     }
     return "_/_";
-}
\ No newline at end of file
+}
diff --git a/examples/cpp/Sample-Transformation/Transformation.cpp b/examples/cpp/Sample-Transformation/Transformation.cpp
index 6b4b412..575781c 100644
--- a/examples/cpp/Sample-Transformation/Transformation.cpp
+++ b/examples/cpp/Sample-Transformation/Transformation.cpp
@@ -312,9 +312,6 @@ int RGBPointCloudTransformation(std::shared_ptr<ob::Device> device) {
             auto          depthFrame = frameset->depthFrame();
             auto          colorFrame = frameset->colorFrame();

-            uint32_t depthWidth = depthFrame->width();
-            uint32_t colorWidth = colorFrame->width();
-
             ob::CoordinateTransformHelper::transformationDepthToRGBDPointCloud(&xyTables, depthFrame->data(), colorFrame->data(), pointPixel);

             saveRGBDPointsDataToPly((uint8_t *)pointcloudData, pointcloudSize, "RGBDDepthPointsWithTables.ply");
@@ -416,8 +413,8 @@ int depth2DToColor2DTransformation(std::shared_ptr<ob::Device> device) {
             // The purpose of converting each point of Depth into the coordinate system of Color is to demonstrate how Depth coordinate points are transformed
             // into Color coordinate points. Due to the coordinate transformation, no hole filling has been performed. Consequently, the converted Depth image
             // may contain hole.
-            for(int i = 0; i < depthFrame->height(); i++) {
-                for(int j = 0; j < depthFrame->width(); j++) {
+            for(uint32_t i = 0; i < depthFrame->height(); i++) {
+                for(uint32_t j = 0; j < depthFrame->width(); j++) {
                     OBPoint2f sourcePixel = { static_cast<float>(j), static_cast<float>(i) };
                     OBPoint2f targetPixel = {};
                     float     depthValue  = *(((uint16_t *)depthFrame->data()) + (i * depthFrame->width()) + j);
@@ -549,7 +546,7 @@ int color2DToDepth2DTransformation(std::shared_ptr<ob::Device> device) {
     return 0;
 }

-int main(int argc, char **argv) try {
+int main() try {

     int case_number = 3;

Could you make changes on your CMakefiles to allow cross-compilation ? For the moment, I have hacked your CMakeLists.txt by this following:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index eddef8b..caa4e99 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1.15)
 project(OrbbecSDK VERSION 1.10.8 LANGUAGES C CXX)

 # Determine host platform
-include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DetermineHostPlatform.cmake)
+set(HOST_PLATFORM "arm64")

 if(WIN32)
     set(ORBBEC_LIB_PREFIX "")

But it will be better to have a CMakeLists.txt which uses the good cmake syntax to manage the cross-compilation case.

Thank you in advance.

@zhonghong322
Copy link
Contributor

Thank you for your feedback. We will consider your suggestions in future versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants