GCC strict compilation failure #27

Closed
sytelus opened this Issue May 21, 2016 · 1 comment

Projects

None yet

2 participants

@sytelus
sytelus commented May 21, 2016 edited

The API_LOG function in dji_sdk_lib\DJI_Type.h is producing unsuppressible error when compiling under stricter mode. People who are using strict compilation as good practice therefore cannot use DJI SDK. Fortunately required change is small. I have modified API_LOG which passes strict compilation and is slightly better and safer than before. It would be great if below change can be applied so we can use strict compilation.

#define API_LOG(driver, title, ... )                                                                                           \
    if ((title))                                                                                                               \
    {                                                                                                                          \
        const int MAX_LEN = 1024;                                                                                              \
        int len = snprintf(DJI::onboardSDK::buffer, MAX_LEN, "%s %s,line %d: ",                                                \
            (title) ? (title) : "NONE", __func__, __LINE__);                                                                   \
        if (len != -1) {                                                                                                       \
            len = snprintf(DJI::onboardSDK::buffer + len, MAX_LEN - len, __VA_ARGS__ );                                        \
            if (len != -1)                                                                                                     \
                (driver)->displayLog();                                                                                        \
            else                                                                                                               \
                (driver)->displayLog("ERROR: could not log because error message printing failed\n");                          \
        }                                                                                                                      \
        else                                                                                                                   \
            (driver)->displayLog("ERROR: could not log because title, line, name printing failed\n");                          \
    }

To enable strict compilation, use following line in CMakeLists.txt (or replace existing one).

set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wextra -Wstrict-aliasing -pedantic -fmax-errors=5 -Werror -Wunreachable-code ${CMAKE_CXX_FLAGS}")

This will produce LOT of errors which would be good to resolve and uncover lot of issues in the code. However given the volume of these it might take longer to cleans your source code. We can currently suppress all of these errors except for above (because GCC doesn't support its suppression yet). So right now only above change is important.

@lanyusea
Member
lanyusea commented Jul 3, 2016

closed because we have updated all codes/docs about the onboard SDK to solve any possible problem.

please reopen the issue if you still suffer the same problem

@lanyusea lanyusea closed this Jul 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment