{"id":7622,"date":"2021-11-02T11:01:33","date_gmt":"2021-11-02T18:01:33","guid":{"rendered":"https:\/\/visualgdb.com\/w\/?p=7622"},"modified":"2021-11-02T11:01:33","modified_gmt":"2021-11-02T18:01:33","slug":"c-style-function-suggestions","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/documentation\/intellisense\/cstyle\/","title":{"rendered":"C-Style Function Suggestions"},"content":{"rendered":"<p>This page describes the C-style function suggestions &#8211; a mechanism suggesting compatible C-style functions for struct and typedef variables.<\/p>\n<h2>Overview<\/h2>\n<p>Starting from VisualGDB 5.6, using the &#8220;.&#8221; or &#8220;-&gt;&#8221; operator on struct and typedef variables automatically suggests the functions that take the corresponding type as an argument: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/01-overview.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7623\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/01-overview.png\" alt=\"\" width=\"573\" height=\"299\" \/><\/a>Selecting such function with &#8220;tab&#8221; or &#8220;enter&#8221; will automatically convert the &#8220;.&#8221; or &#8220;-&gt;&#8221; operator into a C-style function call:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/suggestion_cropped.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7628\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/suggestion_cropped.gif\" alt=\"\" width=\"782\" height=\"259\" \/><\/a><\/p>\n<h2>Customizing the View<\/h2>\n<p>VisualGDB shows the suggested C-style functions as if they were coming from a base C++ class. As long as the &#8220;Show non-inherited members first&#8221; option <strong>(1)<\/strong> is enabled, they will appear after the actual fields. You can also explicitly restrict the suggestion list to the fields <strong>(2)<\/strong>, or disable C-style function suggestion altogether via\u00a0<strong><span id=\"FullSettingPath\">Tools-&gt;Options-&gt;Text Editor-&gt;C\/C++(VisualGDB)-&gt;Advanced-&gt;Code Completion-&gt;Treat C functions as methods<\/span><\/strong>. <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/02-options.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7626\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/02-options.png\" alt=\"\" width=\"624\" height=\"257\" \/><\/a><\/p>\n<h2>Supported Types<\/h2>\n<p>C-style function suggestions compute the actual type of the expression to the left of the &#8220;.&#8221; or &#8220;-&gt; &#8220;operator. Hence, they will work with:<\/p>\n<ul>\n<li>Simple variables<\/li>\n<li>Fields of other variables<\/li>\n<li>Variables defined via preprocessor macros<\/li>\n<\/ul>\n<p>VisualGDB will automatically recognize if the function takes a pointer to the type, and will insert &#8220;&amp;&#8221; if needed.<\/p>\n<p>C-style function suggestions also work for typedef-ed types, such as handles. E.g. defining &#8220;typedef int SOCKET&#8221; will recognize all functions accepting <strong>SOCKET<\/strong> as a first argument:<\/p>\n<p><a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/sock.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7627\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/sock.png\" alt=\"\" width=\"470\" height=\"211\" \/><\/a>Note that it will not work for types defined via preprocessor (#define SOCKET int).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This page describes the C-style function suggestions &#8211; a mechanism suggesting compatible C-style functions for struct and typedef variables. Overview<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[239],"tags":[52],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/7622"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=7622"}],"version-history":[{"count":2,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/7622\/revisions"}],"predecessor-version":[{"id":7631,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/7622\/revisions\/7631"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=7622"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=7622"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=7622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}