{"id":3124,"date":"2023-06-06T11:38:17","date_gmt":"2023-06-06T06:08:17","guid":{"rendered":"https:\/\/www.rangakrish.com\/?p=3124"},"modified":"2023-06-06T11:38:17","modified_gmt":"2023-06-06T06:08:17","slug":"c23-stacktrace-library","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2023\/06\/06\/c23-stacktrace-library\/","title":{"rendered":"C++23: &#8220;stacktrace&#8221; Library"},"content":{"rendered":"<p>The ability to enumerate stack frames at runtime is one of the interesting features introduced in <em><strong>C++23<\/strong><\/em>. This is made possible through the <em><strong>&lt;stacktrace&gt;<\/strong><\/em> header.<\/p>\n<p>The interface is quite simple. Here is a piece of code showing how to use the library.<\/p>\n<figure id=\"attachment_3125\" aria-describedby=\"caption-attachment-3125\" style=\"width: 550px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source1.jpg?ssl=1\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" data-attachment-id=\"3125\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2023\/06\/06\/c23-stacktrace-library\/source1-2\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source1.jpg\" data-orig-size=\"911,644\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1685950675&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Enumerating Stack Frames\" data-image-description=\"&lt;p&gt;Enumerating Stack Frames&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Enumerating Stack Frames&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source1.jpg\" class=\"wp-image-3125\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source1.jpg?resize=550%2C389&#038;ssl=1\" alt=\"Enumerating Stack Frames\" width=\"550\" height=\"389\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source1.jpg?resize=300%2C212&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source1.jpg?resize=768%2C543&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source1.jpg?w=911&amp;ssl=1 911w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><figcaption id=\"caption-attachment-3125\" class=\"wp-caption-text\"><strong>Enumerating Stack Frames<\/strong><\/figcaption><\/figure>\n<p>There are 4 functions and here is the call chain:<\/p>\n<figure id=\"attachment_3126\" aria-describedby=\"caption-attachment-3126\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/call-chain.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3126\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2023\/06\/06\/c23-stacktrace-library\/call-chain\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/call-chain.png\" data-orig-size=\"539,125\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"The Call Chain\" data-image-description=\"&lt;p&gt;The Call Chain&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;The Call Chain&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/call-chain.png\" class=\"wp-image-3126\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/call-chain.png?resize=500%2C116&#038;ssl=1\" alt=\"The Call Chain\" width=\"500\" height=\"116\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/call-chain.png?resize=300%2C70&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/call-chain.png?w=539&amp;ssl=1 539w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-3126\" class=\"wp-caption-text\"><strong>The Call Chain<\/strong><\/figcaption><\/figure>\n<p>The <em><strong>\u201cdumpStackTrace()\u201d<\/strong><\/em> function gets the currently active stack frame sequence, enumerates over each frame and dumps the function name, source file and line number.<\/p>\n<p>Here is the program output:<\/p>\n<figure id=\"attachment_3127\" aria-describedby=\"caption-attachment-3127\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/output1.jpg?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3127\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2023\/06\/06\/c23-stacktrace-library\/output1-13\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/output1.jpg\" data-orig-size=\"838,800\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1685950494&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Program Output\" data-image-description=\"&lt;p&gt;Program Output&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Program Output&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/output1.jpg\" class=\"wp-image-3127\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/output1.jpg?resize=500%2C477&#038;ssl=1\" alt=\"Program Output\" width=\"500\" height=\"477\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/output1.jpg?resize=300%2C286&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/output1.jpg?resize=768%2C733&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/output1.jpg?w=838&amp;ssl=1 838w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-3127\" class=\"wp-caption-text\"><strong>Program Output<\/strong><\/figcaption><\/figure>\n<p>The output shows 10 stack frames, starting with <em><strong>\u201cdumpStackTrace()\u201d<\/strong><\/em>, going up to <em><strong>\u201cmain()\u201d<\/strong><\/em> and even beyond. Keep in mind that this information is implementation dependent.<\/p>\n<p>Let us now set a breakpoint in the code and look at the stack structure at runtime within <em><strong>Visual Studio IDE<\/strong><\/em>. Here is the code with breakpoint:<\/p>\n<figure id=\"attachment_3128\" aria-describedby=\"caption-attachment-3128\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source-with-brkpt.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3128\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2023\/06\/06\/c23-stacktrace-library\/source-with-brkpt\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source-with-brkpt.jpg\" data-orig-size=\"982,238\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1685950736&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Setting Breakpoint in Code\" data-image-description=\"&lt;p&gt;Setting Breakpoint in Code&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Setting Breakpoint in Code&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source-with-brkpt.jpg\" class=\"wp-image-3128\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source-with-brkpt.jpg?resize=500%2C121&#038;ssl=1\" alt=\"Setting Breakpoint in Code\" width=\"500\" height=\"121\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source-with-brkpt.jpg?resize=300%2C73&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source-with-brkpt.jpg?resize=768%2C186&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source-with-brkpt.jpg?w=982&amp;ssl=1 982w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-3128\" class=\"wp-caption-text\"><strong>Setting Breakpoint in Code<\/strong><\/figcaption><\/figure>\n<p>When you debug this program, control stops at the breakpoint and you can see the active stack frames:<\/p>\n<figure id=\"attachment_3129\" aria-describedby=\"caption-attachment-3129\" style=\"width: 550px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/debug-stack-trace.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3129\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2023\/06\/06\/c23-stacktrace-library\/debug-stack-trace\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/debug-stack-trace.jpg\" data-orig-size=\"851,388\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1685950786&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Debug Stack Trace\" data-image-description=\"&lt;p&gt;Debug Stack Trace&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Debug Stack Trace&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/debug-stack-trace.jpg\" class=\"wp-image-3129\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/debug-stack-trace.jpg?resize=550%2C251&#038;ssl=1\" alt=\"Debug Stack Trace\" width=\"550\" height=\"251\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/debug-stack-trace.jpg?resize=300%2C137&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/debug-stack-trace.jpg?resize=768%2C350&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/debug-stack-trace.jpg?w=851&amp;ssl=1 851w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><figcaption id=\"caption-attachment-3129\" class=\"wp-caption-text\"><strong>Debug Stack Trace<\/strong><\/figcaption><\/figure>\n<p>You can see that this more or less matches our earlier output.<\/p>\n<p>If needed, we can get the number of active stack frames in the current environment and access any of these frames using the indexing <em><strong>\u201c[]\u201d<\/strong><\/em> operator. This is shown in the revised <em><strong>\u201cdumpStackTrace()\u201d<\/strong><\/em> function:<\/p>\n<figure id=\"attachment_3130\" aria-describedby=\"caption-attachment-3130\" style=\"width: 550px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source2.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3130\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2023\/06\/06\/c23-stacktrace-library\/source2-2\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source2.jpg\" data-orig-size=\"907,335\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1685951738&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Accessing Stack Frames Directly\" data-image-description=\"&lt;p&gt;Accessing Stack Frames Directly&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Accessing Stack Frames Directly&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source2.jpg\" class=\"wp-image-3130\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source2.jpg?resize=550%2C203&#038;ssl=1\" alt=\"Accessing Stack Frames Directly\" width=\"550\" height=\"203\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source2.jpg?resize=300%2C111&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source2.jpg?resize=768%2C284&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/source2.jpg?w=907&amp;ssl=1 907w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><figcaption id=\"caption-attachment-3130\" class=\"wp-caption-text\"><strong>Accessing Stack Frames Directly<\/strong><\/figcaption><\/figure>\n<p>Here, I am only accessing the topmost 4 frames (up to <em><strong>\u201cmain()\u201d<\/strong><\/em>). This is the corresponding output:<\/p>\n<figure id=\"attachment_3131\" aria-describedby=\"caption-attachment-3131\" style=\"width: 450px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/output2.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3131\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2023\/06\/06\/c23-stacktrace-library\/output2-15\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/output2.jpg\" data-orig-size=\"615,393\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1685951781&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Controlled Access to Stack Frames\" data-image-description=\"&lt;p&gt;Controlled Access to Stack Frames&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Controlled Access to Stack Frames&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/output2.jpg\" class=\"wp-image-3131\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/output2.jpg?resize=450%2C288&#038;ssl=1\" alt=\"Controlled Access to Stack Frames\" width=\"450\" height=\"288\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/output2.jpg?resize=300%2C192&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/output2.jpg?resize=140%2C90&amp;ssl=1 140w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/output2.jpg?w=615&amp;ssl=1 615w\" sizes=\"(max-width: 450px) 100vw, 450px\" \/><\/a><figcaption id=\"caption-attachment-3131\" class=\"wp-caption-text\"><strong>Controlled Access to Stack Frames<\/strong><\/figcaption><\/figure>\n<p>The <em><strong>&lt;stacktrace&gt;<\/strong><\/em> library, while permitting access to the individual stack frames with basic details, doesn\u2019t allow us to access the contained local variables. Maybe that will be part of a future extension.<\/p>\n<p>Since this feature is part of <em><strong>C++23<\/strong><\/em>, you have to enable the corresponding setting in <em><strong>Visual Studio<\/strong><\/em>:<\/p>\n<figure id=\"attachment_3132\" aria-describedby=\"caption-attachment-3132\" style=\"width: 450px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/Settings.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3132\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2023\/06\/06\/c23-stacktrace-library\/settings\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/Settings.jpg\" data-orig-size=\"1180,820\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1685974041&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Enabling C++23 Language Support\" data-image-description=\"&lt;p&gt;Enabling C++23 Language Support&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Enabling C++23 Language Support&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/Settings-1024x712.jpg\" class=\"wp-image-3132\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/Settings.jpg?resize=450%2C313&#038;ssl=1\" alt=\"Enabling C++23 Language Support\" width=\"450\" height=\"313\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/Settings.jpg?resize=300%2C208&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/Settings.jpg?resize=1024%2C712&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/Settings.jpg?resize=768%2C534&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/06\/Settings.jpg?w=1180&amp;ssl=1 1180w\" sizes=\"(max-width: 450px) 100vw, 450px\" \/><\/a><figcaption id=\"caption-attachment-3132\" class=\"wp-caption-text\"><strong>Enabling C++23 Language Support<\/strong><\/figcaption><\/figure>\n<p>I used <em><strong>Visual Studio 2022<\/strong><\/em> (64 bit Edition), version <em><strong>17.6.2<\/strong><\/em> for this experiment.<\/p>\n<p>Have a great week!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The ability to enumerate stack frames at runtime is one of the interesting features introduced in C++23. This is made possible through the &lt;stacktrace&gt; header. The interface is quite simple. Here is a piece of code showing how to use the library. There are 4 functions and here is the call chain: The \u201cdumpStackTrace()\u201d function [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[49,17],"tags":[361,363],"class_list":["post-3124","post","type-post","status-publish","format-standard","hentry","category-c","category-programming","tag-c23","tag-stacktrace-library"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-Oo","jetpack-related-posts":[{"id":1770,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/11\/10\/calling-c-methods-from-sicstus-prolog-through-com-interface\/","url_meta":{"origin":3124,"position":0},"title":"Calling C# Methods from Sicstus Prolog through COM Interface","author":"admin","date":"November 10, 2019","format":false,"excerpt":"Recently\u00a0I needed to make use of a C# library (which I had implemented a few years ago) from Sicstus Prolog. Calling C\/C++ functions from Sicstus Prolog is fairly well documented. When it comes to C#\/.NET, the official documentation recommends the PrologBeans library. After going through the documentation, I felt that\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/www.rangakrish.com\/index.php\/category\/programming\/"},"img":{"alt_text":"Prolog Client Code","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/11\/Prolog-Code.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/11\/Prolog-Code.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/11\/Prolog-Code.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2351,"url":"https:\/\/www.rangakrish.com\/index.php\/2021\/03\/14\/calling-c-methods-from-lispworks-lisp-part-2\/","url_meta":{"origin":3124,"position":1},"title":"Calling C# Methods from LispWorks Lisp &#8211; Part 2","author":"admin","date":"March 14, 2021","format":false,"excerpt":"In the last article, I showed how we can invoke C# methods from LispWorks Enterprise Edition, through the COM\/Automation interface. That approach relied on invoking the Automation methods dynamically, without depending on the Type library (*.tlb).\u00a0 In this article, I will discuss the other approach, which uses the Type library.\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"C# Code","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/03\/Code2-236x300.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/03\/Code2-236x300.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/03\/Code2-236x300.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2242,"url":"https:\/\/www.rangakrish.com\/index.php\/2020\/12\/20\/jfugue-a-java-library-for-music-synthesis\/","url_meta":{"origin":3124,"position":2},"title":"JFugue: A Java Library for Music Synthesis","author":"admin","date":"December 20, 2020","format":false,"excerpt":"JFugue\u00a0is an open-source Java library that can be used for algorithmic music composition. Developed by David Koelle, currently it is in its fifth major version. You can get the library from here. I had downloaded the library some time ago, but could not spend much time since my primary focus\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"Simple Java Program","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/12\/java-2-300x142.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/12\/java-2-300x142.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/12\/java-2-300x142.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":4299,"url":"https:\/\/www.rangakrish.com\/index.php\/2026\/05\/14\/c23-slicing-with-stdviewschunk\/","url_meta":{"origin":3124,"position":3},"title":"C++23: Slicing with std::views::chunk","author":"admin","date":"May 14, 2026","format":false,"excerpt":"One of the common use cases in programming involves extracting fixed size chunks from a given sequence and operating on them. Not a big deal at all. As a C++ developer, I have coded this quite often and have wished that the language had a built-in function for this. Fortunately,\u2026","rel":"","context":"In &quot;C++&quot;","block_context":{"text":"C++","link":"https:\/\/www.rangakrish.com\/index.php\/category\/c\/"},"img":{"alt_text":"Using the chunk function","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/05\/example1-300x259.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/05\/example1-300x259.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2026\/05\/example1-300x259.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2334,"url":"https:\/\/www.rangakrish.com\/index.php\/2021\/02\/28\/calling-c-methods-from-lispworks-lisp-through-com-interface\/","url_meta":{"origin":3124,"position":4},"title":"Calling C# Methods from LispWorks Lisp through COM Interface","author":"admin","date":"February 28, 2021","format":false,"excerpt":"In an earlier article, I showed how to invoke C# methods from Sicstus Prolog. Today, I would like to detail the steps for doing the same from LispWorks Lisp. LispWorks Enterprise Edition comes budled with support for COM and Automation. This is what we will be using. What this means\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"The COM Server in C#","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/02\/C-Code-300x267.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2789,"url":"https:\/\/www.rangakrish.com\/index.php\/2022\/05\/04\/using-dll-functions-in-rust\/","url_meta":{"origin":3124,"position":5},"title":"Using DLL Functions in Rust","author":"admin","date":"May 4, 2022","format":false,"excerpt":"When you program in Rust, especially in a non-trivial project, there is a good chance that you will need to call \"external\" functions (usually, C\/C++) that are available in a DLL (we are talking about the Windows platform here). It could be because you wish to re-use some code that\u2026","rel":"","context":"In &quot;C++&quot;","block_context":{"text":"C++","link":"https:\/\/www.rangakrish.com\/index.php\/category\/c\/"},"img":{"alt_text":"New DLL Project","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/05\/DLL-Project-300x211.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/05\/DLL-Project-300x211.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/05\/DLL-Project-300x211.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/3124","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/comments?post=3124"}],"version-history":[{"count":0,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/3124\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=3124"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=3124"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=3124"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}