{"id":6216,"date":"2024-01-27T00:01:20","date_gmt":"2024-01-27T08:01:20","guid":{"rendered":"https:\/\/c-for-dummies.com\/blog\/?p=6216"},"modified":"2024-01-20T13:00:09","modified_gmt":"2024-01-20T21:00:09","slug":"the-c23-deprecated-and-removed-collection","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=6216","title":{"rendered":"The C23 Deprecated and Removed Collection"},"content":{"rendered":"<p>As with all language updates, things change. Some of these items are deprecated while others are outright removed. Here&#8217;s the list.<br \/>\n<!--more--><br \/>\nAccording to the <a href=\"https:\/\/en.cppreference.com\/w\/c\/23\" rel=\"noopener\" target=\"_blank\">cppreference.com<\/a> website, the following items are removed from the C language with the C23 standard:<\/p>\n<p>&bull; Old-style function declarations and definitions you&#8217;ve probably never used, but which are defined in the original K&#038;R. For example:<\/p>\n<p><code>int swap(a,b)<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;int *a, b;<br \/>\n{<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;\/* stuff *\/<br \/>\n}<\/code><\/p>\n<p>I don&#8217;t know anyone who declares a function with the variable list presented as above. The current form was introduced with C89.<\/p>\n<p>&bull; Representations for signed integers other than two&#8217;s complement.<\/p>\n<p>Without getting too geeky, signed integer values typically range from -2<sup>n-1<\/sup> to +2<sup>n-1<\/sup>-1. For example, -128 through 127 for a <em>signed char<\/em> data type. Some obscure compilers set these values as -127 through 127, which isn&#8217;t supported in the C23 standard.<\/p>\n<p>&bull; Permission that u\/U-prefixed character constants and string literals may be not UTF-16\/32<br \/>\n&bull; Mixed wide string literal concatenation<\/p>\n<p>Both of these items can be confusing, but they&#8217;re cleaning up definitions for wide and multibyte characters. The C23 standard brings consistency to expressing wide character and multibyte literals by removing the old definitions for the <code>u<\/code> and <code>U<\/code> character prefixes that were inconsistent or ill-defined.<\/p>\n<p>&bull; Support for calling <em>realloc()<\/em> with zero size<\/p>\n<p>The <em>realloc()<\/em> function can reallocate a memory chunk to zero bytes. When you do so, different things can happen depending on the compiler, e.g., is the memory block freed? In the C23 standard, the behavior of reallocating memory to zero bytes is officially flagged as &#8220;undefined.&#8221;<\/p>\n<p>&bull; <em>__alignof_is_defined<\/em> and <em>__alignas_is_defined<\/em><\/p>\n<p>These macros are removed in C23. If used, they return constant 1 (TRUE).<\/p>\n<p>&bull; <em>static_assert<\/em> is not provided as a macro defined in <code><assert.h><\/code><br \/>\n&bull; <em>thread_local<\/em> is not provided as a macro defined in <code><threads.h><\/code><\/p>\n<p>The old <em>static_assert<\/em> macro is now the new keyboard <em>_Static_assert<\/em>; <em>thread_local<\/em> becomes keyword <em>_Thread_local<\/em>.<\/p>\n<p>The list of Deprecated items is rather long but contains a few things you may recognize. Before showing the list, remember that deprecated doesn&#8217;t mean that the function or feature is no longer available. It means that you should avoid using the functions in future code as a better, stronger way to do the task is available.<\/p>\n<p>Two functions being deprecated as <em>asctime()<\/em> and <em>ctime()<\/em>.<\/p>\n<p>The <em>asctime()<\/em> function converts a time\/date value stored in a <code>tm<\/code> structure into a string. The string isn&#8217;t the issue, but rather that values in the <code>tm<\/code> structure can be out of range. The function&#8217;s behavior for dealing with out of range values is undefined, which is probably why this function is being deprecated. The <em>asctime_s()<\/em> function can be used as a substitute.<\/p>\n<p>The <em>ctime()<\/em> function converts a clock tick (<em>time_t<\/em>) value into a string. If I&#8217;m reading the docs correctly, this function works by calling the <em>asctime()<\/em> function internally, which would explain why it&#8217;s also being deprecated. The substitute function is <em>ctime_s()<\/em>.<\/p>\n<p>The deprecated list also includes the <code>stdnoreturn.h<\/code> header file plus a few macros I&#8217;m unfamiliar with. The <code>math.h<\/code> defined constants\/macros <code>INFINITY<\/code>, <code>DEC_INFINITY<\/code>, <code>NAN<\/code>, and <code>DEC_NAN<\/code> are now found in the <code>float.h<\/code> header file.<\/p>\n<p>You can view more details at the <a href=\"https:\/\/en.cppreference.com\/w\/c\/23\" rel=\"noopener\" target=\"_blank\">cppreference.com<\/a> website. The site also features a table that shows current compilers and their C23 status.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Review what&#8217;s gone bye-bye and what&#8217;s about to leave the C language as defined in the new C23 standard. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=6216\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-6216","post","type-post","status-publish","format-standard","hentry","category-main"],"_links":{"self":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6216","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6216"}],"version-history":[{"count":6,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6216\/revisions"}],"predecessor-version":[{"id":6223,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6216\/revisions\/6223"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}