2

I'm porting some very old C/C++ code to a C++ app in Xcode 7. I have one source file that contains a very large switch statement (40 cases) in which each case is denoted by a 2-byte constant, and, no surprise, I get a huge list of warnings about using multibyte constants, and I am well aware of the portability issues. The code even has a coping mechanism from long ago:

if LSB

        ((char*)&code)[1]   =   sym[0];
        ((char*)&code)[0]   =   sym[1];

else

        ((char*)&code)[0]   =   sym[0];
        ((char*)&code)[1]   =   sym[1];

endif

        #endif
        switch(code)    {
          case  'PU':

...etc...

I've spent some time with various ways to use constants or macros to represent the various case values, but nothing is quite as readable as simply keeping the 2-byte constants. Is there any way to tell Xcode to be quiet about that particular message for that particular source file? I still want other warnings, and even multibyte constant warnings in other source files. How can I communicate that to Xcode?

Community
  • 1
  • 1
Logicrat
  • 4,438
  • 16
  • 22
  • 1
    This should do it for you: http://stackoverflow.com/questions/7159348/disable-single-warning-error – Aidan Gomez Sep 22 '15 at 21:19
  • Wow, that appears to have worked. The given answers seem to refer to Visual Studio, but when I wrapped my big `case` statement in the `pragma` wrapper, Xcode stopped complaining. Thanks. – Logicrat Sep 22 '15 at 21:28
  • @AidanGomez that link is for Visual Sutdio, not Xcode. – dangerousdave Jul 29 '19 at 20:10

0 Answers0