简体   繁体   中英

Error: this statement may fall through [-Werror=implicit-fallthrough=]

I am trying to compile mitk on ubuntu and I got this error:

error: this statement may fall through [-Werror=implicit-fallthrough=]

Here there is a part of code:

      /** Get memory offset for a given image index */
      unsigned int GetOffset(const IndexType & idx) const
      {
       const unsigned int * imageDims = m_ImageDataItem->m_Dimensions;

        unsigned int offset = 0;
        switch(VDimension)
        {
        case 4:
         offset = offset + idx[3]*imageDims[0]*imageDims[1]*imageDims[2];
        case 3:
        offset = offset + idx[2]*imageDims[0]*imageDims[1];
        case 2:
        offset  = offset + idx[0] + idx[1]*imageDims[0];
         break;
        }

        return offset;
      }

I would be appreciate for any help please.

I am trying to compile mitk on ubuntu and I got this error :

error: this statement may fall through [-Werror=implicit-fallthrough=]

Here there is a part of code :

      /** Get memory offset for a given image index */
      unsigned int GetOffset(const IndexType & idx) const
      {
       const unsigned int * imageDims = m_ImageDataItem->m_Dimensions;

        unsigned int offset = 0;
        switch(VDimension)
        {
        case 4:
         offset = offset + idx[3]*imageDims[0]*imageDims[1]*imageDims[2];
        case 3:
        offset = offset + idx[2]*imageDims[0]*imageDims[1];
        case 2:
        offset  = offset + idx[0] + idx[1]*imageDims[0];
         break;
        }

        return offset;
      }

I would be appreciate for any help please.

I am trying to compile mitk on ubuntu and I got this error :

error: this statement may fall through [-Werror=implicit-fallthrough=]

Here there is a part of code :

      /** Get memory offset for a given image index */
      unsigned int GetOffset(const IndexType & idx) const
      {
       const unsigned int * imageDims = m_ImageDataItem->m_Dimensions;

        unsigned int offset = 0;
        switch(VDimension)
        {
        case 4:
         offset = offset + idx[3]*imageDims[0]*imageDims[1]*imageDims[2];
        case 3:
        offset = offset + idx[2]*imageDims[0]*imageDims[1];
        case 2:
        offset  = offset + idx[0] + idx[1]*imageDims[0];
         break;
        }

        return offset;
      }

I would be appreciate for any help please.

I am trying to compile mitk on ubuntu and I got this error :

error: this statement may fall through [-Werror=implicit-fallthrough=]

Here there is a part of code :

      /** Get memory offset for a given image index */
      unsigned int GetOffset(const IndexType & idx) const
      {
       const unsigned int * imageDims = m_ImageDataItem->m_Dimensions;

        unsigned int offset = 0;
        switch(VDimension)
        {
        case 4:
         offset = offset + idx[3]*imageDims[0]*imageDims[1]*imageDims[2];
        case 3:
        offset = offset + idx[2]*imageDims[0]*imageDims[1];
        case 2:
        offset  = offset + idx[0] + idx[1]*imageDims[0];
         break;
        }

        return offset;
      }

I would be appreciate for any help please.

Assuming the code is correct, just add -Wno-implicit-fallthrough to the compiler flags if you can. This is often CFLAGS or CXXFLAGS in the Makefile.

As others have said, the code for cases 4, 3, and 2 will be executed in that order when VDimension is 4 because there are no break statements to stop it. If that's the intended behavior (and I suspect it is) then the compiler is annoyingly warning you that the switch statement is doing exactly what it should do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM