Skint007 Skint007 - 3 months ago 26
C++ Question

C++ Disable C1061 error - blocks nested to deep?

I'm working with an opensource project(a server) and basically on start it loads a big xml item database, with hundreds of item attributes. It uses a massive amount of else/ifs to check for these attributes, I've taken the liberty of adding about 20 more, and now it seems that I've broken the compiler. I've searched around and none of the answers I've found actually give me a viable option so I'm just wondering if you can disable this, I've tried using #pragma (as they use this on a few other warnings themselves).
I haven't had much experience with this part of C++ so I'm probably doing it wrong.

#pragma warning(disable:1061)

is what I tried, didn't work gave me and error that its not a valid warning. Is it possible to disable this error?

Thank you.

//Edit - Solution
Just wanted to add how I worked around this. I ended up creating a function that I put all my custom attributes in so I wouldn't pass the 128 level limit.

bool isCustomAttribute(std::string strValue, int intValue, xmlNodePtr itemAttributesNode, ItemType& it)

and I inserted into the array of else ifs lol, maybe not pretty but it was a quick and easy work around.


You cannot inhibit this error, as it is a fatal compiler error, not a warning. Its documentation says:

Compiler limit : blocks nested too deeply

Nesting of code blocks exceeds the limit of 128 nesting levels. Simplify nesting.

This is a limit of the compiler, but note that 128 nesting levels is far too much in terms of readability and maintainability. You should refactor that code to reach a saner level of nesting (e.g. four levels or less).