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

GCC strict compilation failure #27

sytelus opened this Issue May 21, 2016 · 1 comment


None yet
2 participants
Copy link

sytelus commented May 21, 2016

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.


This comment has been minimized.

Copy link

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

wzli pushed a commit to rapyuta-robotics/Onboard-SDK-ROS that referenced this issue Aug 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.