-3

I have tried to find some posts or articles but I cant seem to find a good explanation on

  • What are deprecated enum types,
  • What deprecated means,
  • How they are declared, or discovered,
  • How should they be handled, (or not)
  • What problems they can cause?

Redirecting me to a helpful article would also be great Thank you very much!

thahgr
  • 718
  • 1
  • 10
  • 27
  • 1
    Possibly related to http://stackoverflow.com/q/5488057/1938163 – Marco A. Jul 10 '14 at 08:31
  • 4
    Could you provide some links to those posts? It isn't clear what you are talking about. – juanchopanza Jul 10 '14 at 08:31
  • 1
    *Deprecated* is the nice way of saying *don't use me ever again* without breaking backwards compatibility – blgt Jul 10 '14 at 08:33
  • @Marco A, this post is not clear to me at all, he knows what he is talking about, i am not.. – thahgr Jul 10 '14 at 08:43
  • @thahgr edits for new users go into a review queue, they might deem your edit not substantial or useful, I'm not sure – Marco A. Jul 10 '14 at 08:47
  • 2
    In general you shouldn't use any greetings or "thanks" in the end. People know you're looking for help and you'll most likely be grateful (since you're using the site), so it's not really necessary. Instead just pick the most useful answer, once your problem is solved or question is answered and mark it as the accepted answer. Also don't forget to upvote content that helped you. – Mario Jul 10 '14 at 08:49
  • Please provide an example of what you are talking about. Things like "hello" and "thank you" are viewed as noise here and normally removed. – n. m. could be an AI Jul 10 '14 at 08:56
  • ok, I just think its common courtesy to say hello and thanks.. if a post is structutred nicely, with paragraphs and bulletpoints, my personal opinion is that its not such a big noise.. – thahgr Jul 10 '14 at 09:04
  • @thahgr: I agree, but I suspect the removal is automated and *this* related discussion is noise. There's a "meta stackoverflow" where you can search for or start discussions about these other matters. – Tony Delroy Jul 10 '14 at 09:13

3 Answers3

3

What are deprecated enum types?

I've never heard that exact wording, but this is essentially an enum (type) marked as deprecated.

What does deprecated mean?

Deprecated means some value, function, or maybe even module is marked as now obsolete or replaced. It still exists for compatibility with older code, but you shouldn't use it in new code anymore unless you really have to. Keep in mind it might be removed in future versions.

How they are declared, or discovered?

I'm not aware of any true standard/cross-platform way to do this, unfortunately. The question linked in the comments has some examples regarding this. If your compiler supports some special markup (#pragma instruction or some kind of attribute), it should issue you a warning or similar, if marked properly.

How should they be handled, (or not)?

As mentioned above, try to avoid stuff marked as deprecated. There's typically some replacement or at least hints on what/how to do it in the future. For example, if you're trying to use some standard library function in MSVC that is marked as deprecated, the compiler will typically tell you which function to use instead.

What problems they can cause?

For now, they most likely won't cause any problem, but you might not be able to utilize all features provided by some library. For example, the classic sprintf() in MSVC never checked the buffer length writing to. If you try using it, you'll get a warning, asking you to use sprintf_s() instead, which will do that security check. You don't have to do so yet (it's marked as deprecated but not removed), but you're essentially missing out. Not to forget that your code might break (and require major rewrites later on), if the deprecated stuff is finally removed.

Community
  • 1
  • 1
Mario
  • 35,726
  • 5
  • 62
  • 78
  • The linked question is about enumerators (enumeration values). To deprecate an enumeration type, you can define it with the C++14-standard `[[deprecated]]` attribute: `enum class [[deprecated]] colors { red, green, blue };`. – Potatoswatter Jul 10 '14 at 09:22
  • Oh nice, yet another way to add keywords? Why can't it just be `deprecated`? :( @Potatoswatter So that's available for all custom types, but not (enum) elements? – Mario Jul 10 '14 at 09:47
  • yep, attributes are sprinkled all over the grammar but enumerators haven't [[yet]] gotten any love. – Potatoswatter Jul 10 '14 at 23:07
2

What are deprecated enum types?

The terminology is ambiguous, but implies some specific enum types have been marked as deprecated using either:

  • a compiler-specific notation, such that there will be a warning or error if they're used, and/or

  • documentation without any technical enforcement (whether e.g. a sweeping corporate "coding standard" requiring that say only C++11 enum classes be used, or an API-specific note that specific enum types are deprecated)

What deprecated means?

That the functionality may be removed in a later version of the system, usually because it is considered inferior (whether to some existing alternative, or in terms of maintainability, performance, robustness etc.) or unimportant.

How they are declared, or discovered?

If the deprecation is being enforced by the compiler, then it will be have to be included in the same translation unit as the enum type: it may be in the same header, or in a general "deprecation.h" header etc.. Here's a few examples for a common compiler:

  • GCC: enum X [ { ... } ] __attribute__ ((deprecated));

    • for individual enumerations: enum X { E1 __attribute__((deprecated)) [ = value ] [ , ... ] };

How should they be handled, (or not)

When you can, you should investigate why they're deprecated and what the alternatives are, and change the code using them to avoid them.

What problems they can cause?

The immediate problem they cause is that your compiler may generate warnings or errors.

They may well be deprecated because it's not the best idea to use them even with the current software - related functionality may be inefficient, buggy, etc.. For example, given enum Image_Format { GIF, PNG, JPEG, SVG };, GIF may be deprecated in a system because PNG has proven better for the system's users - e.g. perhaps because it supports better colour depth, preserving the colours more accurately, or SVG might be deprecated because some clients have been found to be using web browsers that won't display them, JPEG might be deprecated because it's known the images in the system aren't natural photographic images and the format gives visually poor results despite larger compressed files, slower processing speed and higher memory usage - lots of possible motivations for making things deprecated.

A bigger but not immediate issue is that they could disappear with the next revision of the software "subsystem" providing them, so if you don't migrate old code off them and avoid creating new code using them, your software will have to be fixed before it can work with the update to that subsystem.

Tony Delroy
  • 102,968
  • 15
  • 177
  • 252
  • thank you for your answer, the terminology is ambiguous due to the fact that i dont know much about the subject – thahgr Jul 10 '14 at 09:43
  • 1
    @thahgr: sure... no harm in that... I hope you've got enough insight now to ask people precisely what they mean next time you hear it, and follow their answers.... Cheers. – Tony Delroy Jul 10 '14 at 09:49
-1

Deprecated means -

  1. You can use this feature in the current latest stable release but this feature will be removed in some future release, but which not mentioned.

  2. They are marked by the library or SDK who created them. Some languages use attirubutes to mark deprecated. Like C# uses - [Obsolete] attributes, I am not sure about C++, do don't know what they use to mark deprecated.

  3. They can be removed in any future release. So if you use them, your code or program might not work in future updates, as the feature might have been removed in that future update.

brainless coder
  • 6,310
  • 1
  • 20
  • 36
  • This expalins what deprecated means, but has nothing to do with the actual question. – pmr Jul 10 '14 at 08:35
  • 1
    Are you really sure he only asked for Enum Deprecation?.. Read the question again. Deprecation is a global concept. It does not stand for any single type like `enum` or `class`. It is not like that enumm deprecation is any different than normal deprecation. – brainless coder Jul 10 '14 at 08:37
  • You assume you know what OP is asking. You don't. There are multiple things he could possibly mean by "deprecated enum types" and 3 of his bullet points depend on it. You answered the bullet point that is obvious. – pmr Jul 10 '14 at 08:47
  • @pmr I am guessing you might know the real answer. I would appreciate if you provide it, I might be wrong, so it might help me know the real answer too. – brainless coder Jul 10 '14 at 08:59
  • @pmr: anyone assumes to know what the OP is asking. including yourself. Your statement is itself an assumption. Different, but still an assumption. – Emilio Garavaglia Jul 10 '14 at 09:16
  • @EmilioGaravaglia Poor wording. I tried to imply that I do **not** know what OP is asking since it is ambiguous. See Tony D's answer for the most likely interpretation. – pmr Jul 10 '14 at 09:20