Thread: Parsing Strings

  1. #16
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >_CRT_INSECURE_DEPRECATE
    This has nothing to do with the ISO C++ standard. It's a Microsoftism for "We know better than you and will give a warning to protect you from yourself. Standards? We don't need no stinking standards!".
    My best code is written with the delete key.

  2. #17
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Ah right
    Reply to: Martyn Lovell
    Microsoft Corp.
    1 Microsoft Way
    Redmond WA USA 98052-6399
    Email: [email protected]
    So it looks like MS is just pestering the standards committee to make the changes, and is trying to force the change by declaring the functions 'deprecated' in their new and wildly popular MSVC 2005 (and freely distributed too, have I mentioned?). Therefore, by popular usage and annoyware they are attempting to influence the bulk of the programming community to either abandon the standard or bring enough pressure on the standards committee to force them to comply. Those bastards!

    **EDIT**
    *Warning: This is a nonstandard program. If it breaks for you, get over it.*
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  3. #18
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Those bastards!
    AKA Stupid. There's far too much existing code that uses the "deprecated" functions, and it wouldn't help compatibility with C either. Both of those are big selling points of C++.

    >**EDIT**
    I added the disclaimer after some goofball tried to drop my rep when it seg faulted on them.
    My best code is written with the delete key.

  4. #19
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Well, strtok IS a bug source. Still, it's stupid of Microsoft to make it deprecated. I would understand, though, if they introduced a similar thing to deprecation into their compiler, but called it insecure.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #20
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Well, strtok IS a bug source.
    Ignorance is a bug source. strtok is one of the functions that are troublesome because the user programmer didn't bother to figure out all of the issues involved in using it. The same can be said of scanf. There's nothing wrong with the functions, just how they're used. If you use them intelligently then there's usually no problem.
    My best code is written with the delete key.

  6. #21
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    You're absolutely right, of course. Still, it's easier to be ignorant of the hazards of strtok than other functions. strtok preserves state, and this is something that mathematically inclined programmers really don't like. To them, a function that is given a specific input returns a specific output, no matter what happened before or after.

    Of course, we could tell these people to use Haskell and go away Even user input functions are wrenched into a functional pattern there.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #22
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Of course, we could tell these people to use Haskell and go away
    Works for me. Tools should be used when they're the best option. Purists are uncomfortable with C++ because it embraces that concept.
    My best code is written with the delete key.

  8. #23
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> This has nothing to do with the ISO C++ standard. It's a Microsoftism...

    sort of like how you have to use WinMain() instead of main(). very annoying.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  9. #24
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Ok, thanks everyone. So, do you figure it's safe for me to go through the CRT code and kill all the annoying and unholy _CRT_INSECURE_DEPRECATED's (and potentially the function_s() prototypes too)?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  10. #25
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >do you figure it's safe for me to go through the CRT code and kill all the annoying and unholy
    Annoying and unholy they may be, but implementation code is sacred. Only edit it if you really really REALLY know what you're doing and are still willing to face the consequences when it turns out that you don't. Safe or not, I wouldn't recommend it. You would be better off using a pragma to disable the warning.
    My best code is written with the delete key.

  11. #26
    Registered User
    Join Date
    Jun 2004
    Posts
    722
    Quote Originally Posted by Sebastiani
    >> This has nothing to do with the ISO C++ standard. It's a Microsoftism...

    sort of like how you have to use WinMain() instead of main(). very annoying.
    that's a main adapted to receive the process' handler and Graphical window flags, since Windows programming has little or nothing has to do with ansi or posix.. but why I'm I saying this? you already know

    Hunter... try #pragma warning(disable:***).
    or more problematic
    #undef _CRT_INSECURE_DEPRECATED
    #define _CRT_INSECURE_DEPRECATED

  12. #27
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    try #pragma warning(disable:***).
    or more problematic
    #undef _CRT_INSECURE_DEPRECATED
    #define _CRT_INSECURE_DEPRECATED
    The problem with the pragma is, every other deprecation warning will go with it. The problem with the #undef is that it's not defined until I include the header, at which point it's too late to undef or define anything. So the solution is,

    #define _CRT_INSECURE_DEPRECATE before I include any standard headers

    Too bad the implementation is sacred.. sure woulda been nice to not need that extra line
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  13. #28
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >The problem with the pragma is, every other deprecation warning will go with it.
    Boo hoo. Buy the standard and then you'll know exactly what's deprecated and what isn't. No need for those silly warnings.

    >sure woulda been nice to not need that extra line
    You could always just ignore the warning, or write a script to take the output and systematically remove the warnings you know are silly, or hire someone to scan your warnings for you and tell you about the ones that are pertinent, or call Billy on the Batphone and order him to take a reality pill, or build a space-time transmogrifier using the gutted carcass of your old VCR, 6 ballpoint pens, and a stick of low-fat margarine so that you can reshape reality as you see fit. Or you could just get over it and start worrying about things that actually matter.
    My best code is written with the delete key.

  14. #29
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    You could always just ignore the warning, or write a script to take the output and systematically remove the warnings you know are silly, or hire someone to scan your warnings for you and tell you about the ones that are pertinent, or call Billy on the Batphone and order him to take a reality pill, or build a space-time transmogrifier using the gutted carcass of your old VCR, 6 ballpoint pens, and a stick of low-fat margarine so that you can reshape reality as you see fit. Or you could just get over it and start worrying about things that actually matter.
    I've just been victimized

    Alright, I guess I'll just ignore the warning for now (that #define seems to be encroaching on implementation-messing territory), since I don't have a copy of the standard and I'm not confident that I know exactly what's deprecated and what's not. Then, if I want to know if the warning is a 'false positive', then I can just look at the CRT source and see if it's another one 'o those dratted _CRT_INSECURE_DEPRECATE's

    Thanks everyone!

    P.S. Prelude, I'll let you know when I have that space-time transmogrifier built
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  15. #30
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    To get a clean compile I'll usually lookup the error code and write a define such as #pragma warning (disable : errorcode)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. parsing command line strings
    By John_L in forum C Programming
    Replies: 15
    Last Post: 05-28-2008, 08:26 AM
  2. sscanf and parsing strings
    By jco1323 in forum C Programming
    Replies: 4
    Last Post: 02-20-2008, 06:32 PM
  3. Parsing Strings
    By SubLogic in forum C++ Programming
    Replies: 15
    Last Post: 01-07-2003, 11:11 AM
  4. Searching and Comparing Strings Using Parsing
    By niroopan in forum C++ Programming
    Replies: 3
    Last Post: 09-28-2002, 10:18 AM
  5. parsing delimited strings
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 11-08-2001, 12:57 PM