error C2220: warning treated as error - no 'object' file generated

前端 未结 5 798
死守一世寂寞
死守一世寂寞 2020-12-15 03:05

I have below class

class Cdata12Mnt
{
public:
    char IOBname[ID1_IOB_PIOTSUP-ID1_IOB_TOP][BOADNAM_MAX + 4];
    char ExIOBname[ID1_MAX_INF-ID1_EXIOB_U1TOP]         


        
相关标签:
5条回答
  • 2020-12-15 03:41

    The error says that a warning was treated as an error. Therefore your problem is a warning message! Check them and fix these.

    In case you don't know how to find them: Open the Error List (View > Error List) and click on Warning.

    0 讨论(0)
  • 2020-12-15 03:43

    This warning is about unsafe use of strcpy. Try IOBname[ii]='\0'; instead.

    0 讨论(0)
  • 2020-12-15 03:45

    Go to project properties -> configurations properties -> C/C++ -> treats warning as error -> No (/WX-).

    0 讨论(0)
  • 2020-12-15 03:46

    As a side-note, you can enable/disable individual warnings using #pragma. You can have a look at the documentation here

    From the documentation:

    // pragma_warning.cpp
    // compile with: /W1
    #pragma warning(disable:4700)
    void Test() {
       int x;
       int y = x;   // no C4700 here
       #pragma warning(default:4700)   // C4700 enabled after Test ends
    }
    
    int main() {
       int x;
       int y = x;   // C4700
    }
    
    0 讨论(0)
  • 2020-12-15 03:55

    This error message is very confusing. I just fixed the other 'warnings' in my project and I really had only one (simple one):

    warning C4101: 'i': unreferenced local variable

    After I commented this unused i, and compiled it, the other error went away.

    0 讨论(0)
提交回复
热议问题