This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Erroneous Warning #370-D: Class <"unnamed>' defines no constructor to initialize the following:

Hi Everyone,

I am using the USB Library from TivaWare with C++ code for my project, and I have run into the following warning:

"C:/TI/TivaWare_C_Series-2.1.0/usblib/device/usbdbulk.h", line 177: warning #370-D: class "<unnamed>" defines no constructor to initialize the following:
            const member "<unnamed>::ui16VID"
            const member "<unnamed>::ui16PID"
            const member "<unnamed>::ui16MaxPowermA"
            const member "<unnamed>::ui8PwrAttributes"
            const member "<unnamed>::pfnRxCallback"
            const member "<unnamed>::pfnTxCallback"
            const member "<unnamed>::ui32NumStringDescriptors"


Since the code in usbdbulk.h is wrapped in extern "C", I don't think that this warning should be coming up.  I am compiling with the latest TI ARM 5.1.6 compiler on Code Composer Studio 6.0.0.

I did some searching and I found this post in the Code Composer Forum that seems to cover this topic: http://e2e.ti.com/support/development_tools/code_composer_studio/f/81/t/335318.aspx.

Is this indeed a compiler bug, or is something else going on that I should be concerned about?

Thanks,
Erik

  • Erik Stafl said:
    Is this indeed a compiler bug

    I filed SDSCM00050391 in the SDOWP system.  That does not mean I agree it is a compiler bug.  But it does mean you make a good point, and we should carefully consider whether it is correct to issue this diagnostic.

    Why is this diagnostic issued?  Because those fields in the structure are declared const, it is not possible for them to be changed in any context other than initialization.  And initialization is normally carried out in a constructor.  There is no constructor for this struct (which is very typical of C code being compiled for C++).  However it is possible to write something like ...

    struct tUSBDBulkDevice global_struct = {
        10,
        20,
        // and so on
    };
    

    That example supports the viewpoint that this diagnostic should not be issued.

    Thanks and regards,

    -George

  • Erik Stafl said:
    Since the code in usbdbulk.h is wrapped in extern "C", I don't think that this warning should be coming up.

    Using extern "C" has no effect on this situation.

    Thanks and regards,

    -George

  • Hi George,

    Thanks for your reply.  Your explanation makes sense to me.  It probably is an unnecessary diagnostic, considering the example you've shown. 

    Have a nice weekend,

    Erik