<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>C on Arcanelab Blog</title><link>https://blog.arcanelab.com/tags/c/</link><description>Recent content in C on Arcanelab Blog</description><generator>Hugo</generator><language>en-US</language><copyright>Zoltán Majoros</copyright><lastBuildDate>Wed, 11 Oct 2023 21:06:00 +0200</lastBuildDate><atom:link href="https://blog.arcanelab.com/tags/c/index.xml" rel="self" type="application/rss+xml"/><item><title>PhysicsFS</title><link>https://blog.arcanelab.com/2023/10/physicsfs/</link><pubDate>Wed, 11 Oct 2023 21:06:00 +0200</pubDate><guid>https://blog.arcanelab.com/2023/10/physicsfs/</guid><description>&lt;h1&gt;&lt;/h1&gt;</description></item><item><title>For the project I’m currently working on, I’m evaluating options for an embeddable…</title><link>https://blog.arcanelab.com/2023/07/for-the-project-im-currently-working-on-im-evaluating/</link><pubDate>Fri, 28 Jul 2023 17:51:00 +0200</pubDate><guid>https://blog.arcanelab.com/2023/07/for-the-project-im-currently-working-on-im-evaluating/</guid><description>&lt;h1&gt;&lt;/h1&gt;
&lt;p&gt;For the project I&amp;rsquo;m currently working on, I&amp;rsquo;m evaluating options for an embeddable scripting language. Here&amp;rsquo;s a shortlist I compiled after researching &lt;a href="https://href.li/?https://github.com/dbohdan/embedded-scripting-languages"&gt;this&lt;/a&gt; list:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="https://href.li/?https://marcobambini.github.io/gravity/"&gt;Gravity&lt;/a&gt; (Swift-like syntax, one of my favs)&lt;/li&gt;&lt;li&gt;&lt;a href="https://href.li/?https://www.lua.org/"&gt;Lua&lt;/a&gt; (The most popular embedded language)&lt;/li&gt;&lt;li&gt;&lt;a href="https://href.li/?https://terralang.org/"&gt;Terra&lt;/a&gt; (A statically-typed Lua-like language)&lt;/li&gt;&lt;li&gt;&lt;a href="https://href.li/?https://github.com/jpoirier/picoc"&gt;PicoC&lt;/a&gt; (Small footprint C interpreter)&lt;/li&gt;&lt;li&gt;&lt;a href="https://href.li/?https://wren.io/"&gt;Wren&lt;/a&gt; (Class-based)&lt;/li&gt;&lt;li&gt;&lt;a href="https://href.li/?https://github.com/GaijinEntertainment/quirrel"&gt;Quirrel&lt;/a&gt; (An improvement on Squirrel)&lt;/li&gt;&lt;li&gt;&lt;a href="https://href.li/?https://www.angelcode.com/angelscript/"&gt;Angelscript&lt;/a&gt; (C/C++ like, popular in game engines)&lt;/li&gt;&lt;li&gt;&lt;a href="https://href.li/?http://chaiscript.com/"&gt;ChaiScript&lt;/a&gt; (Easy-to-integrate, C++ based)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Here&amp;rsquo;s a benchmark of many scripting languages: &lt;a href="https://href.li/?https://github.com/r-lyeh-archived/scriptorium"&gt;https://github.com/r-lyeh-archived/scriptorium&lt;/a&gt;&lt;/p&gt;</description></item><item><title>fgetwc, getwc - cppreference.com</title><link>https://blog.arcanelab.com/2023/07/fgetwc-getwc-cppreference-com/</link><pubDate>Wed, 19 Jul 2023 22:19:00 +0200</pubDate><guid>https://blog.arcanelab.com/2023/07/fgetwc-getwc-cppreference-com/</guid><description>&lt;h1&gt;&lt;/h1&gt;</description></item><item><title>How do I enable SSE4.1 and SSE3 (but NOT AVX) in MSVC</title><link>https://blog.arcanelab.com/2023/07/how-do-i-enable-sse4-1-and-sse3-but-not-avx-in-msvc/</link><pubDate>Tue, 11 Jul 2023 23:00:00 +0200</pubDate><guid>https://blog.arcanelab.com/2023/07/how-do-i-enable-sse4-1-and-sse3-but-not-avx-in-msvc/</guid><description>&lt;h1&gt;&lt;/h1&gt;</description></item><item><title>SDL2 common mistakes and how to avoid them</title><link>https://blog.arcanelab.com/2023/07/sdl2-common-mistakes-and-how-to-avoid-them/</link><pubDate>Mon, 10 Jul 2023 01:45:00 +0200</pubDate><guid>https://blog.arcanelab.com/2023/07/sdl2-common-mistakes-and-how-to-avoid-them/</guid><description>&lt;h1&gt;&lt;/h1&gt;</description></item><item><title>{n} times faster than C - part one</title><link>https://blog.arcanelab.com/2023/07/n-times-faster-than-c-part-one/</link><pubDate>Thu, 06 Jul 2023 23:19:00 +0200</pubDate><guid>https://blog.arcanelab.com/2023/07/n-times-faster-than-c-part-one/</guid><description>&lt;h1&gt;&lt;/h1&gt;</description></item><item><title>How to Create a Modern C Project with CMake and Conan</title><link>https://blog.arcanelab.com/2023/05/how-to-create-a-modern-c-project-with-cmake-and-conan/</link><pubDate>Sun, 14 May 2023 14:27:00 +0200</pubDate><guid>https://blog.arcanelab.com/2023/05/how-to-create-a-modern-c-project-with-cmake-and-conan/</guid><description>&lt;h1&gt;&lt;/h1&gt;</description></item><item><title>floooh/sokol</title><link>https://blog.arcanelab.com/2018/09/floooh-sokol/</link><pubDate>Thu, 27 Sep 2018 23:35:00 +0200</pubDate><guid>https://blog.arcanelab.com/2018/09/floooh-sokol/</guid><description/></item><item><title>Unity C# Tutorials</title><link>https://blog.arcanelab.com/2017/08/unity-c-tutorials/</link><pubDate>Tue, 01 Aug 2017 16:18:00 +0200</pubDate><guid>https://blog.arcanelab.com/2017/08/unity-c-tutorials/</guid><description/></item><item><title>Swift And C: Everything You Need to Know on Types, Pointers and more</title><link>https://blog.arcanelab.com/2017/05/swift-and-c-everything-you-need-to-know-on-types-pointers/</link><pubDate>Tue, 23 May 2017 17:03:00 +0200</pubDate><guid>https://blog.arcanelab.com/2017/05/swift-and-c-everything-you-need-to-know-on-types-pointers/</guid><description/></item><item><title>Writing a Linux Kernel Driver for an Unknown USB Device</title><link>https://blog.arcanelab.com/2017/04/writing-a-linux-kernel-driver-for-an-unknown-usb-device/</link><pubDate>Sat, 15 Apr 2017 23:46:00 +0200</pubDate><guid>https://blog.arcanelab.com/2017/04/writing-a-linux-kernel-driver-for-an-unknown-usb-device/</guid><description/></item><item><title>Modern C++ in embedded systems – Part 1: Myth and Reality</title><link>https://blog.arcanelab.com/2017/04/modern-c-in-embedded-systems-part-1-myth-and-reality/</link><pubDate>Wed, 12 Apr 2017 14:22:00 +0200</pubDate><guid>https://blog.arcanelab.com/2017/04/modern-c-in-embedded-systems-part-1-myth-and-reality/</guid><description/></item><item><title>Obsessive Coding Disorder, Julian Storer - JUCE Summit keynote 2015</title><link>https://blog.arcanelab.com/2016/12/obsessive-coding-disorder-julian-storer-juce-summit-keynote/</link><pubDate>Wed, 28 Dec 2016 17:49:00 +0100</pubDate><guid>https://blog.arcanelab.com/2016/12/obsessive-coding-disorder-julian-storer-juce-summit-keynote/</guid><description>&lt;div class="caption"&gt;&lt;blockquote&gt;&lt;p&gt;Julian Storer, the founder of JUCE, rewrites one of the most used C 
library in the world, Zlib. In doing so, Julian showcases the coding 
standards that apply to the JUCE library. Watch on to see how many lines
of code Julian managed to reduce Zlib to, while improving drastically 
the readability of the code and removing all dependencies.&lt;br/&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;/div&gt;</description></item><item><title>C++ for Games: Performance. Allocations and Data Locality</title><link>https://blog.arcanelab.com/2016/05/c-for-games-performance-allocations-and-data-locality/</link><pubDate>Mon, 30 May 2016 12:52:00 +0200</pubDate><guid>https://blog.arcanelab.com/2016/05/c-for-games-performance-allocations-and-data-locality/</guid><description/></item><item><title>Clang Environment variable for linker path</title><link>https://blog.arcanelab.com/2016/05/clang-environment-variable-for-linker-path/</link><pubDate>Wed, 04 May 2016 22:37:00 +0200</pubDate><guid>https://blog.arcanelab.com/2016/05/clang-environment-variable-for-linker-path/</guid><description/></item><item><title>stb single-file public domain libraries for C/C++</title><link>https://blog.arcanelab.com/2016/04/stb-single-file-public-domain-libraries-for-c-c/</link><pubDate>Tue, 26 Apr 2016 22:23:00 +0200</pubDate><guid>https://blog.arcanelab.com/2016/04/stb-single-file-public-domain-libraries-for-c-c/</guid><description/></item><item><title>How to C (as of 2016)</title><link>https://blog.arcanelab.com/2016/01/how-to-c-as-of-2016/</link><pubDate>Sat, 09 Jan 2016 03:05:00 +0100</pubDate><guid>https://blog.arcanelab.com/2016/01/how-to-c-as-of-2016/</guid><description/></item><item><title>ANSI C Lex/Yacc Grammar http://www.quut.com/c/ANSI-C-grammar-y.html…</title><link>https://blog.arcanelab.com/2015/05/ansi-c-lex-yacc-grammar-http-www-quut-com-c-ansi-c-grammar/</link><pubDate>Tue, 19 May 2015 16:45:00 +0200</pubDate><guid>https://blog.arcanelab.com/2015/05/ansi-c-lex-yacc-grammar-http-www-quut-com-c-ansi-c-grammar/</guid><description>&lt;h1&gt;ANSI C Lex/Yacc Grammar&lt;/h1&gt;
&lt;p&gt;&lt;a href="http://www.quut.com/c/ANSI-C-grammar-y.html"&gt;http://www.quut.com/c/ANSI-C-grammar-y.html&lt;/a&gt;&lt;a href="http://www.quut.com/c/ANSI-C-grammar-l.html"&gt;&lt;br/&gt;http://www.quut.com/c/ANSI-C-grammar-l.html&lt;/a&gt;&lt;br/&gt;&lt;/p&gt;</description></item><item><title>iroundf A few minutes ago I wrote a rounding function for myself in C.</title><link>https://blog.arcanelab.com/2010/09/iroundf-a-few-minutes-ago-i-wrote-a-rounding-function-for/</link><pubDate>Wed, 29 Sep 2010 04:00:00 +0200</pubDate><guid>https://blog.arcanelab.com/2010/09/iroundf-a-few-minutes-ago-i-wrote-a-rounding-function-for/</guid><description>&lt;h1&gt;iroundf&lt;/h1&gt;
&lt;p&gt;A few minutes ago I wrote a rounding function for myself in C. Probably not the best implementation, but it works all right. If you&amp;rsquo;re interested, check it out (I&amp;rsquo;ve put some sample values in the comments):&lt;/p&gt;
&lt;pre&gt;int iroundf(float value)&lt;br/&gt;{&lt;br/&gt;    if(value &amp;gt; 0.0)&lt;br/&gt;    {        &lt;br/&gt;        int unsigned cutvalue = (unsigned int)value; // 3.8234234 =&amp;gt; 3&lt;br/&gt;        float remain = value - cutvalue; // 3.8234234-3 = 0.8234234&lt;br/&gt;        &lt;br/&gt;        if(remain &amp;gt;= 0.5) // 0.8234234 &amp;gt;= 0.5 =&amp;gt; TRUE &lt;br/&gt;            return cutvalue + 1; // iroundf(3.8234234) =&amp;gt; 4&lt;br/&gt;        else&lt;br/&gt;            return cutvalue;&lt;br/&gt;    }&lt;br/&gt;    &lt;br/&gt;    if(value &amp;lt; 0.0)&lt;br/&gt;    {&lt;br/&gt;        int cutvalue = (int)value; // -1.34 =&amp;gt; -1 // -4.67 =&amp;gt; -4&lt;br/&gt;        float remain = value - cutvalue; // -1.34-(-1) = -0.34 // -4.64-(-4) = -0.64&lt;br/&gt;        &lt;br/&gt;        if(remain &amp;gt;= -0.5) // -0.31 &amp;gt;= -0.5 =&amp;gt; TRUE // -0.61 &amp;gt;= -0.5 =&amp;gt; FALSE&lt;br/&gt;            return cutvalue; // iroundf(-1.34) =&amp;gt; -1&lt;br/&gt;        else&lt;br/&gt;            return cutvalue - 1; // iroundf(-4.67) =&amp;gt; -5&lt;br/&gt;    }&lt;br/&gt;    &lt;br/&gt;    return 0;&lt;br/&gt;}&lt;br/&gt;&lt;br/&gt;&lt;/pre&gt;
&lt;p&gt;update: I just came across the following very short and elegant solution (talk about forests and trees&amp;hellip;)&lt;/p&gt;</description></item><item><title>C/C++ trick with logical operators Let me show a nice C/C++ trick I just found out:…</title><link>https://blog.arcanelab.com/2010/09/c-c-trick-with-logical-operators-let-me-show-a-nice-c-c/</link><pubDate>Sat, 04 Sep 2010 02:14:00 +0200</pubDate><guid>https://blog.arcanelab.com/2010/09/c-c-trick-with-logical-operators-let-me-show-a-nice-c-c/</guid><description>&lt;h1&gt;C/C++ trick with logical operators&lt;/h1&gt;
&lt;p&gt;Let me show a nice C/C++ trick I just found out:&lt;/p&gt;
&lt;p&gt;Instead of writing:&lt;/p&gt;
&lt;pre&gt;if (function1())&lt;br/&gt; function2();&lt;/pre&gt;
&lt;p&gt;you could write:&lt;/p&gt;
&lt;pre&gt;function1() &amp;amp;&amp;amp; function2();&lt;/pre&gt;
&lt;p&gt;because the right side of the &amp;amp;&amp;amp; operator is only evaluated (in this case: called), when function1() is true (returns a non-null value).&lt;/p&gt;
&lt;p&gt;Subsequently, instead of:&lt;/p&gt;
&lt;pre&gt;if (!function1()) // or if (function1()==0) etc.&lt;br/&gt; function2();&lt;/pre&gt;
&lt;p&gt;you could write:&lt;/p&gt;
&lt;pre&gt;function1() || function2();&lt;/pre&gt;
&lt;p&gt;Cool, eh?&lt;/p&gt;</description></item></channel></rss>