mathstodon.xyz is one of the many independent Mastodon servers you can use to participate in the fediverse.
A Mastodon instance for maths people. We have LaTeX rendering in the web interface!

Server stats:

2.8K
active users

#endif

0 posts0 participants0 posts today
NCommander<p>So today I learned something</p><p>If neither BIG_ENDIAN, LITTLE_ENDIAN or BYTE_SWAP are defined, and you do:</p><p><a href="https://social.restless.systems/tags/if" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>if</span></a> BYTE_ORDER == LITTLE_ENDIAN<br>// code goes here<br><a href="https://social.restless.systems/tags/endif" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>endif</span></a><br><a href="https://social.restless.systems/tags/if" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>if</span></a> BYTE_ORDER == BIG_ENDIAN<br>// code goes here<br><a href="https://social.restless.systems/tags/endif" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>endif</span></a></p><p>The if states both evaluate to if 0 == 0, and thus becomes 1 and both lines get included. This just bit my Linux kernel build on XP ...</p>
Rob Amos (Bok)<p><span class="h-card" translate="no"><a href="https://mastodon.social/@mattiem" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>mattiem</span></a></span> eg rather than</p><p><a href="https://mastodon.social/tags/if" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>if</span></a> os(macOS) || os(iOS) || os(tvOS)<br><a href="https://mastodon.social/tags/endif" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>endif</span></a> </p><p>Define it in Package.swift</p><p>swiftSettings: [<br> .define("SUPPORTS_MYFEATURE", .when(platforms: [ .macOS, .iOS, .tvOS ]))<br> ]</p><p>and <a href="https://mastodon.social/tags/if" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>if</span></a> SUPPORTS_MYFEATURE everywhere is easier to understand intent (and keep up to date when platforms change) 😊</p>
Izumi Tsutsui<p>/* Get address of this CPU's current battable */<br>+<a href="https://social.mikutter.hachune.net/tags/if" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>if</span></a> 1<br>+<a href="https://social.mikutter.hachune.net/tags/if" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>if</span></a> 1<br>+ lis %r30,_C_LABEL(cpu_info)@ha;<br>+ addi %r30,%r30,_C_LABEL(cpu_info)@l;<br>+<a href="https://social.mikutter.hachune.net/tags/else" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>else</span></a><br> GET_CPUINFO(%r30)<br>+<a href="https://social.mikutter.hachune.net/tags/endif" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>endif</span></a><br> ldreg %r30,CI_BATTABLE(%r30)<br>+<a href="https://social.mikutter.hachune.net/tags/else" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>else</span></a><br>+ lis %r30,_C_LABEL(battable)@ha<br>+ addi %r30,%r30,_C_LABEL(battable)@l<br>+<a href="https://social.mikutter.hachune.net/tags/endif" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>endif</span></a><br> <br>GET_CPUINFO() の mfsprg r,0 を使わないようにしても動かないのは変わらない、というのがそれを裏付けている気はする(さすがに CI_BATTABLE の offsetof() は間違えようがないはず……)</p>
Izumi Tsutsui<p>--- a/sys/arch/powerpc/powerpc/trap_subr.S<br>+++ b/sys/arch/powerpc/powerpc/trap_subr.S<br>@@ -269,8 +269,13 @@ _C_LABEL(dsitrap):<br> /* get segment * 8 */<br> <br> /* Get address of this CPU's current battable */<br>+<a href="https://social.mikutter.hachune.net/tags/if" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>if</span></a> 0<br> GET_CPUINFO(%r30)<br> ldreg %r30,CI_BATTABLE(%r30)<br>+<a href="https://social.mikutter.hachune.net/tags/else" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>else</span></a><br>+ lis %r30,_C_LABEL(battable)@ha<br>+ addi %r30,%r30,_C_LABEL(battable)@l<br>+<a href="https://social.mikutter.hachune.net/tags/endif" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>endif</span></a><br> <br> /* Add offset to the slot we care about. */<br> add %r31,%r31,%r30</p><p>これで動くということは GET_CPUINFO が途中で差し替わっているということ??</p>
ity<pre><code>static const struct memdev {<br> const char *name;<br> const struct file_operations *fops;<br> fmode_t fmode;<br> umode_t mode;<br>} devlist[] = {<br>#ifdef CONFIG_DEVMEM<br> [DEVMEM_MINOR] = { "mem", &amp;mem_fops, 0, 0 },<br>#endif<br> [3] = { "null", &amp;null_fops, FMODE_NOWAIT, 0666 },<br>#ifdef CONFIG_DEVPORT<br> [4] = { "port", &amp;port_fops, 0, 0 },<br>#endif<br> [5] = { "zero", &amp;zero_fops, FMODE_NOWAIT, 0666 },<br> [7] = { "full", &amp;full_fops, 0, 0666 },<br> [8] = { "random", &amp;random_fops, FMODE_NOWAIT, 0666 },<br> [9] = { "urandom", &amp;urandom_fops, FMODE_NOWAIT, 0666 },<br>#ifdef CONFIG_PRINTK<br> [11] = { "kmsg", &amp;kmsg_fops, 0, 0644 },<br>#endif<br>};<br></code></pre>
ity<pre><code>#ifdef CONFIG_PROC_FS<br><br>void chrdev_show(struct seq_file *f, off_t offset)<br>{<br> struct char_device_struct *cd;<br><br> mutex_lock(&amp;chrdevs_lock);<br> for (cd = chrdevs[major_to_index(offset)]; cd; cd = cd-&gt;next) {<br> if (cd-&gt;major == offset)<br> seq_printf(f, "%3d %s\n", cd-&gt;major, cd-&gt;name);<br> }<br> mutex_unlock(&amp;chrdevs_lock);<br>}<br><br>#endif /* CONFIG_PROC_FS */<br></code></pre><p><code>fs/char_dev.c</code></p><p>This is evil. Evil. Just evil. Why Linus oh why why why why why did you merge this code 19 years ago</p>
A.M. Rowsell<p><span class="h-card" translate="no"><a href="https://mastodon.social/@jaromil" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>jaromil</span></a></span> Ran it manually, and it generated a file with the <a href="https://social.sdf.org/tags/ifndef" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ifndef</span></a> __ASSETS_H__ <a href="https://social.sdf.org/tags/def" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>def</span></a> __ASSETS_H__ and nothing else in the file, which causes a different error. I'm on Arch, have quite a bit of experience compiling code from various projects, but I don't know enough about the build process here to figure out why it's making essentially a blank file (with no <a href="https://social.sdf.org/tags/endif" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>endif</span></a>)</p>
wirepair<p>fucking hell winspool.h:</p><p><a href="https://mastodon.social/tags/ifdef" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ifdef</span></a> UNICODE<br><a href="https://mastodon.social/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> AddJob AddJobW<br><a href="https://mastodon.social/tags/else" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>else</span></a><br><a href="https://mastodon.social/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> AddJob AddJobA<br><a href="https://mastodon.social/tags/endif" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>endif</span></a> // !UNICODE</p><p>Jolt defines a class method called...<br>virtual void AddJob(const JobHandle &amp;inJob) override;</p><p>guess some ordering got re-arranged and now my shit is conflicting</p>
pwm<p><span class="h-card"><a class="u-url mention" href="https://clubcyberia.co/users/RustyCrab" rel="nofollow noopener noreferrer" target="_blank">@<span>RustyCrab</span></a></span> <span class="h-card"><a class="u-url mention" href="https://socially.drinkingatmy.computer/users/prettygood" rel="nofollow noopener noreferrer" target="_blank">@<span>prettygood</span></a></span> </p><pre><code>/* Exit with a status code indicating success. Copyright (C) 1999-2025 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;. */ <a class="hashtag" href="https://darkdork.dev/tag/include" rel="nofollow noopener noreferrer" target="_blank">#include</a> &lt;config.h&gt; <a class="hashtag" href="https://darkdork.dev/tag/include" rel="nofollow noopener noreferrer" target="_blank">#include</a> &lt;stdio.h&gt; <a class="hashtag" href="https://darkdork.dev/tag/include" rel="nofollow noopener noreferrer" target="_blank">#include</a> &lt;sys/types.h&gt; <a class="hashtag" href="https://darkdork.dev/tag/include" rel="nofollow noopener noreferrer" target="_blank">#include</a> "system.h" /* Act like "true" by default; false.c overrides this. */ <a class="hashtag" href="https://darkdork.dev/tag/ifndef" rel="nofollow noopener noreferrer" target="_blank">#ifndef</a> EXIT_STATUS # define EXIT_STATUS EXIT_SUCCESS <a class="hashtag" href="https://darkdork.dev/tag/endif" rel="nofollow noopener noreferrer" target="_blank">#endif</a> <a class="hashtag" href="https://darkdork.dev/tag/if" rel="nofollow noopener noreferrer" target="_blank">#if</a> EXIT_STATUS == EXIT_SUCCESS # define PROGRAM_NAME "true" <a class="hashtag" href="https://darkdork.dev/tag/else" rel="nofollow noopener noreferrer" target="_blank">#else</a> # define PROGRAM_NAME "false" <a class="hashtag" href="https://darkdork.dev/tag/endif" rel="nofollow noopener noreferrer" target="_blank">#endif</a> <a class="hashtag" href="https://darkdork.dev/tag/define" rel="nofollow noopener noreferrer" target="_blank">#define</a> AUTHORS proper_name ("Jim Meyering") void usage (int status) { printf (_("\ Usage: %s [ignored command line arguments]\n\ or: %s OPTION\n\ "), program_name, program_name); printf ("%s\n\n", _(EXIT_STATUS == EXIT_SUCCESS ? N_("Exit with a status code indicating success.") : N_("Exit with a status code indicating failure."))); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); emit_ancillary_info (PROGRAM_NAME); exit (status); } int main (int argc, char **argv) { /* Recognize --help or --version only if it's the only command-line argument. */ if (argc == 2) { initialize_main (&amp;argc, &amp;argv); set_program_name (argv[0]); setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); /* Note true(1) will return EXIT_FAILURE in the edge case where writes fail with GNU specific options. */ atexit (close_stdout); if (STREQ (argv[1], "--help")) usage (EXIT_STATUS); if (STREQ (argv[1], "--version")) version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS, (char *) nullptr); } return EXIT_STATUS; } </code></pre>
Soybean<p><a href="https://mastodon.ktachibana.party/tags/C" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>C</span></a><br>经常在一些厂家SDK看到有变量define在header里<br>为了防止重复linker还特意加了<br><a href="https://mastodon.ktachibana.party/tags/ifndef" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ifndef</span></a> __XXXXX_C<br>extern .....;<br><a href="https://mastodon.ktachibana.party/tags/else" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>else</span></a><br>.....;<br><a href="https://mastodon.ktachibana.party/tags/endif" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>endif</span></a><br>这是为了什么呢</p>
Marieke<p>vim % on `<a href="https://hachyderm.io/tags/if" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>if</span></a>` `<a href="https://hachyderm.io/tags/else" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>else</span></a>` `<a href="https://hachyderm.io/tags/endif" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>endif</span></a>` is so helpful.</p>
Thierry Laurion<p><span class="h-card" translate="no"><a href="https://mas.to/@libreleah" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>libreleah</span></a></span> <span class="h-card" translate="no"><a href="https://mas.to/@mkukri" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>mkukri</span></a></span> </p><p>Both Heads and lbmk permit to apply patches on top of a coreboot fork. </p><p>The difference between the two here is that lbmk builds the tree, clean, for each boards, where Heads applies the patches to a fork once, and each board reuses fork build artifacts;, building board specifics in a board specific artifact directory. That permits crossgcc, being the buildstack of each coreboot fork version to be built once, and also repro build issues upstream, economizing both disk space, cpu resource for user and CI.</p><p>In Heads goal of building fully functional roms, CI can build and stitch reproducible roms for each commit for end users to download directly from CI, for each commit, and see if a comit broke a built, for each commit. CI cache is reused, so that we don't waste CI resources either.</p><p>In the case of t480, the patch was made with lbmk in mind, not coreboot nor Heads, and breaks other thinkpads in coreboot upstream, trying to not only build for t480 but make sure t480 patchset doesn't break other boards. In this case, it breaks all other thinkpads, so prevent Heads from merging the PR. What you propose here is for libreboot and Heads to maintain a patchset not merged upstream; it might suit libreboot mindset, being more bleeding edge, and minifree, selling the t480, but not Heads. Heads tries to stay as close as possible to upstream forks, and pushes upstream projects to merge patches. Its long, not easy, but the right thing to do. The patches stays in a patch dir for everyone to see, per software version. In this case, patches/coreboot-24.12/*</p><p>I tried to apply the following patch without success instead of commenting thermal.asl</p><p>+diff --git a/src/ec/lenovo/h8/acpi/ec.asl b/src/ec/lenovo/h8/acpi/ec.asl<br>+index bc54d3b..a0408c8 100644<br>+--- a/src/ec/lenovo/h8/acpi/ec.asl<br>++++ b/src/ec/lenovo/h8/acpi/ec.asl<br>+@@ -331,7 +331,13 @@ Device(EC)<br>+ <a href="https://infosec.exchange/tags/include" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>include</span></a> "sleepbutton.asl"<br>+ <a href="https://infosec.exchange/tags/include" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>include</span></a> "lid.asl"<br>+ <a href="https://infosec.exchange/tags/include" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>include</span></a> "beep.asl"<br>++<br>++<a href="https://infosec.exchange/tags/ifndef" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ifndef</span></a> CONFIG_BOARD_LENOVO_T480<br>+ <a href="https://infosec.exchange/tags/include" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>include</span></a> "thermal.asl"<br>++<a href="https://infosec.exchange/tags/else" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>else</span></a><br>++//#include "thermal.asl"<br>++<a href="https://infosec.exchange/tags/endif" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>endif</span></a><br>++<br>+ <a href="https://infosec.exchange/tags/include" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>include</span></a> "systemstatus.asl"<br>+ <a href="https://infosec.exchange/tags/include" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>include</span></a> "thinkpad.asl"<br>+ }</p><p>Other non t480 fail to build, and I have no more time to spend on this. The community is interested, tried to reach libreboot and were seen as spammers.</p><p>Please fix your patchset upstream. People saw the t480 being "supported by coreboot" in a talk. People didn't understand it was a WiP patchset under coreboot. And here we are. 24.12 was december 2024 "release", there will be another one in 25.03... I do not have time to maintain patches on top of patches, Leah. My focus is not to be a coreboot distribution. My focus is to deliver reproducible roms to users needing accessible security, and improve that UX. There is no grub/seabios under Heads, my focus is to make upstream do the right thing and participate upstream, and make contributors participate upstream. Here, you stated loud and clear tha libreboot comes first before coreboot, I respect that. But the t480 patchset is the one too from upstream. That upstream patch needs to build, and then will be merged and then you won't have to maintain it either. And others will fix audio issues, nvidia etc. Otherwise its silo work, and i'm not interested in that anymore</p><p>---</p><p>Yes, there is different coreboot forks specified in a central place: modules/coreboot. </p><p>And there, the buildsystem says if it can reuse crossgcc of another fork to fasten builds for each commit. The idea here is that the user building one board, or multiple boards will get the same result, but CI building multiple boards based on the same fork will speed up builds massively.</p><p>d16 will move to fam15h fork from other community effort. I mentor now, I don't try to do everything myself. Just as here, trying tto collaborate with you so you fix what was brought up upstream. But up to now, you are upstream for t480.</p><p>The goal here was not to compare our buildsystems, simply stating that the patchset upstream will never be merged if it causes regressions building other boards. Libreboot can do what it wants, but needs to respect how coreboot works. Their CI does the same, and make sure that building a commit for a board won't break others. In current case, it breaks others and needs to be updated.</p><p>This needs to be fixed upstream at <a href="https://review.coreboot.org/c/coreboot/+/83274" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">review.coreboot.org/c/coreboot</span><span class="invisible">/+/83274</span></a></p>
Izumi Tsutsui<p>ibus-1.5.32-beta2/portal/ibus-portal-dbus.c<br>と<br>ibus-1.5.32-rc1/portal/ibus-portal-dbus.c<br>で<br>- g_variant_builder_init (&amp;builder, G_VARIANT_TYPE ("a{sv}"));<br>+<a href="https://social.mikutter.hachune.net/tags/if" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>if</span></a> GLIB_VERSION_MAX_ALLOWED &gt;= GLIB_VERSION_2_84<br>+ g_variant_builder_init_static (&amp;builder, G_VARIANT_TYPE ("a{sv}"));<br>+<a href="https://social.mikutter.hachune.net/tags/else" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>else</span></a><br>+ g_variant_builder_init(&amp;builder, G_VARIANT_TYPE ("a{sv}"));<br>+<a href="https://social.mikutter.hachune.net/tags/endif" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>endif</span></a><br>という差分があってここでコケているっぽいが、これが github には入ってなくて生成ファイルっぽい?<br>よくわからん設定やめて</p>
Craig Hockenberry<p>Good news: there's code for it:</p><p><a href="https://mastodon.social/tags/ifndef" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ifndef</span></a> ZAHL<br><a href="https://mastodon.social/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> ZAHL 0<br><a href="https://mastodon.social/tags/endif" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>endif</span></a></p><p>Bad news: XOR-ing a value with 0 isn't going to help. It's a NOP.</p><p>And it's intentional, for example:</p><p>ts ^= ZAHL; /* hehe */</p><p>I can’t reverse engineer the real value of ZAHL without knowing the original timestamp.</p><p>It might be possible to do an exhaustive search, but time_t is a long long and my time is short short.</p><p>So no blog.fefe.de for Tapestry. Sorry!</p><p>3/3</p>
Patrick McConnell<p>A note related to yesterdays thoughts on creating preview data:</p><p>One drawback is the issue when you try to create a release build and are swamped with errors that all the cool things you created for your previews don't exist.</p><p><a href="https://mastodon.social/tags/if" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>if</span></a> (DEBUG)<br><a href="https://mastodon.social/tags/Preview" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Preview</span></a> {…}<br><a href="https://mastodon.social/tags/endif" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>endif</span></a></p><p>fixes it but really shouldn't be necessary</p><p>I feel like the Preview macro could be improved to handle this? </p><p> <a href="https://mastodon.social/tags/SwiftUI" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>SwiftUI</span></a> <a href="https://mastodon.social/tags/SwiftData" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>SwiftData</span></a> <a href="https://mastodon.social/tags/iOSDev" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>iOSDev</span></a></p>
simon<p><a href="https://fosstodon.org/tags/c" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>c</span></a> <a href="https://fosstodon.org/tags/programming" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>programming</span></a> </p><p>C header files usually have a guard to prevent them being included more than once. Quite often these take the form of</p><p><a href="https://fosstodon.org/tags/ifndef" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ifndef</span></a> THING</p><p><a href="https://fosstodon.org/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> THING</p><p>/* Header content. */</p><p><a href="https://fosstodon.org/tags/endif" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>endif</span></a> </p><p>Where THING is loosely derived from the filename itself.</p><p>I now prefer this at the top of the file:</p><p><a href="https://fosstodon.org/tags/pragma" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>pragma</span></a> once</p><p>And none of the rest of that boilerplate.</p><p>It's not standard but supported by all compilers I tried. If you know of corner cases where this doesn't work, I'd like to hear from you 🙂</p>
robrich<p><a href="https://khalidabuhakmeh.com/unit-tests-for-legacy-systems-with-dotnet-6" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">khalidabuhakmeh.com/unit-tests</span><span class="invisible">-for-legacy-systems-with-dotnet-6</span></a> - in <a href="https://hachyderm.io/tags/dotNET" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>dotNET</span></a>, use a compiler directive to <a href="https://hachyderm.io/tags/mock" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>mock</span></a> <a href="https://hachyderm.io/tags/static" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>static</span></a> classes:<br>```<br><a href="https://hachyderm.io/tags/if" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>if</span></a> MOCK_TIME<br>global using DateTimeOffset = StubDateTimeOffset; <br><a href="https://hachyderm.io/tags/else" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>else</span></a><br>global using DateTimeOffset = System.DateTimeOffset;<br><a href="https://hachyderm.io/tags/endif" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>endif</span></a> <br>```<br>Sweet technique <span class="h-card" translate="no"><a href="https://mastodon.social/@khalidabuhakmeh" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>khalidabuhakmeh</span></a></span>.</p>
zhenech<p><a href="https://chaos.social/tags/if" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>if</span></a> 0<br> // Original; this will do strict check which will fail<br> // with entries that …<br> …<br><a href="https://chaos.social/tags/else" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>else</span></a><br> &lt;code that does less validation&gt;<br><a href="https://chaos.social/tags/endif" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>endif</span></a></p><p>Ah yes, thanks for patching this nice RCE in.</p>
Julian Andres Klode 🏳️‍🌈<p>GCC is so annoying, the error attribute can only be set on functions, but I want to set it on namespaces and types too.</p><p>Basically I want to define</p><p>```<br><a href="https://mastodon.social/tags/ifdef" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ifdef</span></a> APT_COMPILING_APT<br><a href="https://mastodon.social/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> APT_INTERNAL <br><a href="https://mastodon.social/tags/else" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>else</span></a><br><a href="https://mastodon.social/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> APT_INTERNAL __attribute__((error("Internal use only")))<br><a href="https://mastodon.social/tags/endif" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>endif</span></a> <br>```</p><p>Such that external users can't use internal types and functions and namespaces that are in the header, without me having to wrap them in ifdef</p>
Andre Weissflog<p><span class="h-card" translate="no"><a href="https://peoplemaking.games/@sol_hsa" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>sol_hsa</span></a></span> <span class="h-card" translate="no"><a href="https://mastodon.gamedev.place/@pythno" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>pythno</span></a></span> fwiw this is what I do in sokol_app.h before including windows.h:</p><p> <a href="https://mastodon.gamedev.place/tags/ifndef" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ifndef</span></a> WIN32_LEAN_AND_MEAN<br> <a href="https://mastodon.gamedev.place/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> WIN32_LEAN_AND_MEAN<br> <a href="https://mastodon.gamedev.place/tags/endif" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>endif</span></a><br> <a href="https://mastodon.gamedev.place/tags/ifndef" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ifndef</span></a> NOMINMAX<br> <a href="https://mastodon.gamedev.place/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> NOMINMAX<br> <a href="https://mastodon.gamedev.place/tags/endif" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>endif</span></a> </p><p>(also I only include windows.h in the implementation, not in the interface declaration)</p>