<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>modern C++ modules: convert existing example from .h to module</title><link>/technologies/code_exchange/b/blog/posts/modern-c-modules-convert-existing-example-from-h-to-module</link><description>I&amp;#39;m experimenting with new C++ constructs. 
In C++ callbacks and templates , I developed a generic object oriented callback handler using templates.In modern C++ modules I tried out an example that uses C++ modules...</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: modern C++ modules: convert existing example from .h to module</title><link>https://community.element14.com/technologies/code_exchange/b/blog/posts/modern-c-modules-convert-existing-example-from-h-to-module</link><pubDate>Sat, 08 Feb 2025 18:52:25 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:4bba44c6-4c40-4a99-98ef-8303509171f3</guid><dc:creator>DAB</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Nice post Jan.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=28696&amp;AppID=74&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: modern C++ modules: convert existing example from .h to module</title><link>https://community.element14.com/technologies/code_exchange/b/blog/posts/modern-c-modules-convert-existing-example-from-h-to-module</link><pubDate>Sat, 08 Feb 2025 18:00:50 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:4bba44c6-4c40-4a99-98ef-8303509171f3</guid><dc:creator>Jan Cumps</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;I used an object&amp;#39;s method as callback handler in the example. But you can as well use a standard c type function. Here&amp;#39;s an example&lt;/p&gt;
&lt;p&gt;[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:34a44791-dee8-4040-bbb9-7c52727e6ba4:type=c_cpp&amp;text=int%20functionHandler%28const%20int%26%20num1%2C%20const%20int%26%20num2%29%20%7B%0A%20%20%20%20return%20num1%20%2B%20num2%3B%0A%7D%0A%0Aint%20main%28%29%20%7B%0A%0A%20%20%20%20int%20a%20%3D%204%3B%0A%20%20%20%20int%20b%20%3D%205%3B%0A%0A%09%2F%2F%20scenario%3A%20call%20C%20function%0A%09callbackmanager%3A%3ACallback%3Cint%2C%20const%20int%26%2C%20const%20int%26%3E%20cb%3B%0A%20%20%20%20%2F%2F%20Use%20a%20lambda%20to%20call%20the%20classic%20C%20function%0A%20%20%20%20cb.set%28%5B%5D%28const%20int%26%20num1%2C%20const%20int%26%20num2%29%20-%3E%20int%20%7B%0A%20%20%20%20%20%20%20%20return%20functionHandler%28num1%2C%20num2%29%3B%0A%20%20%20%20%7D%29%3B%0A%0A%20%20%20%20int%20o%20%3D%20cb.call%28a%2C%20b%29%3B%0A%20%20%20%20printf%28%22Value%3A%20%25i%5Cn%22%2C%20o%29%3B%0A%09fflush%28stdout%29%3B]&lt;/p&gt;
&lt;p&gt;It calls function&amp;nbsp;&lt;span&gt;functionHandler().&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You an also use it to call plain c code that&amp;#39;s not in a function (a lambda). See all options in&amp;nbsp;&amp;nbsp;[mention:5b356e0658814266b1c94f99fba9084c:46448885d0e64133bbfbf0cd7b0fd6f7]&amp;nbsp;&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=28696&amp;AppID=74&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item></channel></rss>