Thread: Switch Problem

  1. #31
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by JVene View Post
    Thus:

    #pragma warning( disable: nnnn );

    where nnnn is the warning number


    For portable code, this should be wrapped in a conditional block for the ms compiler
    This disables the warning from there onward, which will silence any such warnings in the following code. Thus you need to do something like this:

    Code:
    #ifdef _MSC_VER // Detect if it's Microsoft's compilers
    #pragma warning(push)
    #pragma warning(disable: nnnn)
    #endif
    // Code
    #ifdef _MSC_VER
    #pragma warning(pop)
    #endif
    Quote Originally Posted by whiteflags View Post
    "A lot of other problems"? Microsoft's warning doesn't even mention why x was deprecated in favor of x_s, so there is no silencing of any issues regardless, it's merely an authoritative tenet. The macro doesn't remove any other warning, either, according to their docs.
    It's clearly outlined in the documentation why to use the *_s versions.
    Warnings aren't always so informative.
    The macro removes ALL warnings about deprecated functions.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #32
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    That would be the point since Microsoft is deciding what is deprecated and what is not, clearly, but there isn't "a lot of other problems". There's no reason why warning can't be made informative either.
    Last edited by whiteflags; 04-25-2009 at 07:08 AM.

  3. #33
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by whiteflags View Post
    That would be the point since Microsoft is deciding what is deprecated and what is not, clearly, but there isn't "a lot of other problems".
    I don't think so.
    They made a point about deprecating non *_s functions because clearly they're dangerous and Microsoft is the company of security. That's basically the only functions in the C library they've deprecated.
    They have full right to deprecate their own API, too, of course, so there's no problem there.

    There's no reason why warning can't be made informative either.
    Warnings usually need to be short enough or we'd full length explanations about every error we get. The term deprecated usually tells a developer "this function might go away soon, so I should avoid it if I can." So it's fitting for a warning, but if it's the best for this kind of warnings is debatable.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #34
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    >> They made a point about deprecating non *_s functions because clearly they're dangerous
    >> and Microsoft is the company of security. That's basically the only functions in the C library
    >> they've deprecated.

    That doesn't mean they can afford to, as they could not eventually declare x obsolete and replaced by x_s and be standards compliant. The warning is being used as a way to say "use our stuff," and in no way reflects the reality of the situation.

    There are better ways to do what Microsoft has achieved, but I don't even have a problem with the route they chose. I just don't want to be warned about it. It obstructs treating warnings as errors.

  5. #35
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Perhaps there are better ways. What way would you choose?
    And I agree the warning isn't the best one - at first I thought those functions would be removed.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #36
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    >> Perhaps there are better ways. What way would you choose?

    People already told you some ways; my thoughts run parallel.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Switch statement problem
    By jalex39 in forum C Programming
    Replies: 6
    Last Post: 03-08-2008, 04:05 PM
  2. problem on switch
    By toxicherry in forum C Programming
    Replies: 11
    Last Post: 12-31-2007, 05:17 AM
  3. Switch Problem
    By Tynnhammar in forum C++ Programming
    Replies: 2
    Last Post: 09-16-2004, 11:57 AM
  4. Replies: 1
    Last Post: 08-31-2004, 04:07 AM
  5. Uh-oh! I am having a major switch problem!
    By goodn in forum C Programming
    Replies: 4
    Last Post: 11-01-2001, 04:49 PM