shakedown.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
A community for live music fans with roots in the jam scene. Shakedown Social is run by a team of volunteers (led by @clifff and @sethadam1) and funded by donations.

Administered by:

Server stats:

255
active users

#define

0 posts0 participants0 posts today
Jonathan Grynspan<p>```<br>/*<br> * This has been tuned to generate reasonable code on the vax using pcc.<br> */<br><a href="https://hachyderm.io/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> __sputc(c, p)<br>```</p><p>sorry what</p>
dotoscat<p>"Me pregunto is C me deja hacer esto"</p><p><a href="https://mastodon.xyz/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> TILES_WIDTH 20<br><a href="https://mastodon.xyz/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> TILES_HEIGHT 15</p><p>SDL_FRect room_collision[TILES_WIDTH*TILES_HEIGHT] = {0};</p><p>Pues me deja</p><p><a href="https://mastodon.xyz/tags/gamedev" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>gamedev</span></a></p>
argv minus one<p><a href="https://mastodon.sdf.org/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> struct union</p>
gloriouscow<p>I'm going to start adding 8086/V30 support. </p><p>The easiest thing to do would be to have a <a href="https://oldbytes.space/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> for it, but that would require reuploading the sketch every time you wanted to switch CPUs. I don't like that, so I think I should auto-detect what CPU you have.</p>
Changelog<p>🚀 It's Changelog &amp; Friends!</p><p>Welcome back to <a href="https://changelog.social/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a>, our game of obscure jargon, fake definitions, and expert tomfoolery. We've gathered some awesome friends, new and old, to see who has the best vocabulary and who can trick the everyone else into thinking that they do.</p><p>✨ <a href="https://changelog.am/93" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="">changelog.am/93</span><span class="invisible"></span></a> <a href="https://changelog.social/tags/podcast" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>podcast</span></a></p>
SpaceLifeForm<p><span class="h-card" translate="no"><a href="https://masto.ai/@GhostOnTheHalfShell" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>GhostOnTheHalfShell</span></a></span> </p><p>The models suck because they give too much weight to old data.</p><p><a href="https://infosec.exchange/tags/Define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Define</span></a> OLDDATA OVER2YEARS </p><p><a href="https://infosec.exchange/tags/WX" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>WX</span></a> <a href="https://infosec.exchange/tags/ClimateChange" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ClimateChange</span></a> <a href="https://infosec.exchange/tags/Models" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Models</span></a></p>
arclight<p>Today's work fun involved my modernized dead-end version of the good sodium fire code (as opposed to SOFIRE II, the bad sodium fire code).</p><p>One of the changes I make in all legacy Fortean codes is to replace 'double precision' numerical types with 'real(kind=real64)'. Modern Fortran has patameterized numerical precision via a 'kind' which is defined as part of the standard library. 'kind' is an enum implemented as an integer constant - the details aren't important - the big idea is that you can define a "working precision" kind constant and use that throughout your code to set precision on constants snd variables. So I define WP as real64 and all my declarations are real(kind=WP). Similarly, all my literals are written as 1.0_WP (the underscore connects the literal value with a type/kind).</p><p>The neat thing is that you can redefine WP as real32 or real128, recompile, and now your reals are all now single or quad precision. No compiler options, no global search-and-replace - just redefine a constant, recompile, and you're done.</p><p>Why do this? Back in the 32-bit days, double precision meant better accuracy but much slowe execution. Engineering code would often ship both single- and double-previsuon versions of an application. Run scoping cases quickly in single precision, switch to double precision for final runs or in cases with noticeable roundoff, stability, or precision issues.</p><p>As an experiment, I rebuilt the code in single and quad precision, ran the test suite and compared the results against the default real64 results. Results for real64 and real128 were mostly identical except for 1-2 parameters in the first 5-6 timesteps when conditions are rapidly changing (start of fire). What's interesting is there's not much numerical "noise" after the first 5-6 timesteps (it helps that the code is only writing 5 significant figures in the data files so much of the noise won't be visable). real32 results had more deviation so clearly real64 is adequate for what we're doing. More bits extends runtime significantly and the results are essentially identical. Fewer bits gives us less accurate results (no great surprise there.)</p><p>I'm curious what I should be looking for in a test like this. I think I need to dig into Nick Higham's book on stability and accuracy <a href="https://nhigham.com/accuracy-and-stability-of-numerical-algorithms/" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">nhigham.com/accuracy-and-stabi</span><span class="invisible">lity-of-numerical-algorithms/</span></a> and see if he has any interesting ideas (this book is above my pay grade...) I really need to generate some plots and look for signs of clipping or instability.</p><p>This is a case where it was easy to run this experiment; I did it just to see what would happen. Now I'm at the point of asking what I should expect to see, what kinds of issues can arise by fiddling with the precision knob, and what conclusions I can draw about code stability from the results.</p><p>Parameterized precision makes this test trivial in Fortran; curious if/how other languages can do this without complier options, macros, and a preprocessor or similar unmaintainable and questionable hackery. It's nice having everything explicitly there in the source code with nary a <a href="https://oldbytes.space/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> in sight.</p>
Andy Sherwood<p><span class="h-card" translate="no"><a href="https://mastodon.social/@caseyliss" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>caseyliss</span></a></span> Back in the day, I was working on some CPP code and had this bug that was killing me. After several hours, I noticed this buried in one of .h files:</p><p><a href="https://mastodon.social/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> TRUE 0</p><p>😖</p>
xchangeee<p><span class="h-card" translate="no"><a href="https://mystical.garden/@janamarie" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>janamarie</span></a></span></p><p> <a href="https://chaos.social/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> _LINUX_ 1</p>
ZXGuesser<p><span class="h-card" translate="no"><a href="https://retrochat.online/@jimblimey" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>jimblimey</span></a></span> looking at the code I included a <a href="https://oldbytes.space/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> to disable them, in a block of stuff marked<br>/* compile time options to reduce toolkit size */</p><p>I think that's about the size of the compiled code rather than memory used by the features.</p>
Sean Murthy<p><span class="h-card" translate="no"><a href="https://infosec.exchange/@mttaggart" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>mttaggart</span></a></span> PR for your consideration:</p><p>```<br>+ <a href="https://hachyderm.io/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> I int</p><p>- int stanbul;<br>+ I stanbul;<br>```</p>
Dave Hayden 🏊<p>Something I should have done a long time ago:</p><p> <a href="https://pdx.social/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> streq(a,b) (strcmp((a),(b))==0)</p><p>I've been writing C code for a few decades now and I still screw up strcmp all the time. I wonder what the total cost of all the bugs that API decision caused adds up to</p>
NuclearOatmeal💥:BOWLSOUP_PNG:<p>In today's adventures of "Hating C because it deserves hatred", I try to compile an old repository at <a href="https://github.com/TinyMUSH/Historical-TinyMUSH" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">github.com/TinyMUSH/Historical</span><span class="invisible">-TinyMUSH</span></a>. It failed.</p><p>I should have realized something was up when I got a lot of warnings at one point due to some issue regarding `inline function 'xyz' declared but never defined`. Not a goodness, but I'd circle back as needed.</p><p>Finally get to the `gcc-g -o` point.</p><p>Boom. `/opt/Historical-TinyMUSH/src/netcommon.c:937: undefined reference to `queue_rawstring'` and others. Thing is, there _is_ an `INLINE void queue_rawstring(d, s)` right there in line 382, and the autoconf.h has it right there with `<a href="https://beige.party/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> INLINE inline`, so... This code gets to be hated.</p><p>Hate Hate Hate.</p><p>So how's your day going?</p>
Raven Luni<p>When you add macros to improve readability and end up with this:</p><p><a href="https://furry.engineer/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> varalloc(s,v) ((VarStack_Push (s, NULL, sizeof (*v))) ? (typeof (v)) ((char *) s + s-&gt;top - sizeof (*v)) : NULL)</p><p>(its for mapping arena memory to native pointers)</p><p><a href="https://furry.engineer/tags/coding" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>coding</span></a> <a href="https://furry.engineer/tags/c" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>c</span></a></p>
SpaceLifeForm<p><a href="https://infosec.exchange/tags/Define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Define</span></a> King "constitutional dementia"</p><p>Watch Lawrence while you can.</p><p><a href="https://www.youtube.com/watch?v=ylxcZNrbfJE" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://www.</span><span class="">youtube.com/watch?v=ylxcZNrbfJE</span><span class="invisible"></span></a></p>
Félix<p><span class="h-card" translate="no"><a href="https://pony.social/@thephd" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>thephd</span></a></span><br>This works to define rsize_t:</p><p><a href="https://tech.lgbt/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> __STDC_WANT_LIB_EXT1__ 1<br><a href="https://tech.lgbt/tags/include" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>include</span></a> &lt;string.h&gt;</p><p>use “xcrun clang -dD -E file.c”, do the same thing with the broken configuration, see where things go wrong. If you do find there’s a problem with the macOS SDK, that sounds fixable</p>
James Chip<p>*stares at code I just found*</p><p>the code:</p><p><a href="https://merveilles.town/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> CFG01 const struct \<br>{ USB_CFG_DSC cd01; \<br> USB_INTF_DSC i00a00; \<br> USB_HID_DSC hid_i00a00; \<br> USB_EP_DSC ep01i_i00a00; \<br> USB_EP_DSC ep01o_i00a00; \<br>} cfg01</p><p>extern CFG01;</p>
Jann Horn<p>inspired by <span class="h-card" translate="no"><a href="https://hachyderm.io/@pinskia" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>pinskia</span></a></span> mentioning <code>musttail</code>, today I learned that you can implement state machines in C such that state transitions are implemented as calls:</p><pre><code>#include &lt;stdlib.h&gt;<br>#include &lt;stdio.h&gt;<br><br>#define VOID __attribute__((noinline)) void<br>#define JUMP [[clang::musttail]] return<br><br>static char *input;<br>static int acc = 0;<br>static int state = 0;<br><br>VOID initial_state(void);<br><br>VOID digit(void) {<br> acc += *(input++) - '0';<br> JUMP initial_state();<br>}<br>VOID separator(void) {<br> state = acc;<br> acc = 0;<br> input++;<br> JUMP initial_state();<br>}<br>VOID add(void) {<br> state += acc;<br> acc = 0;<br> input++;<br> JUMP initial_state();<br>}<br>VOID minus(void) {<br> state -= acc;<br> acc = 0;<br> input++;<br> JUMP initial_state();<br>}<br><br>VOID initial_state(void) {<br> switch (*input) {<br> case '0'...'9':<br> JUMP digit();<br> case ' ':<br> JUMP separator();<br> case '+':<br> JUMP add();<br> case '-':<br> JUMP minus();<br> default:<br> printf("result: %d\n", state);<br> exit(0);<br> }<br>}<br><br>int main(int argc, char **argv) {<br> puts("welcome to my calculator");<br> input = argv[1];<br> initial_state();<br>}<br></code></pre><p>compiles to stuff like this, all jumps:</p><pre><code>add:<br> mov eax, dword ptr [rip + acc]<br> add dword ptr [rip + state], eax<br> mov dword ptr [rip + acc], 0<br> inc qword ptr [rip + input]<br> jmp initial_state<br></code></pre><p>And the security benefits are obvious! The less stack you have, the less potential for the stack pointer being hijacked! 😆</p>
Foone🏳️‍⚧️<p>I love finding a function that does nothing and is called from 100 places with a debug string.</p><p>SOMEONE TURNED OFF A <a href="https://digipres.club/tags/DEFINE" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>DEFINE</span></a> AND THEIR COMPILER DOESN'T KNOW WHAT OPTIMIZATION IS</p>
Lorenzo Stoakes<p><span class="h-card" translate="no"><a href="https://infosec.exchange/@jann" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>jann</span></a></span> I mean equally:</p><p><a href="https://fosstodon.org/tags/define" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>define</span></a> _GNU_SOURCE<br><a href="https://fosstodon.org/tags/include" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>include</span></a> &lt;err.h&gt;<br><a href="https://fosstodon.org/tags/include" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>include</span></a> &lt;stdio.h&gt;<br><a href="https://fosstodon.org/tags/include" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>include</span></a> &lt;sys/mman.h&gt;<br>int main(void) {<br> char *p = mmap(NULL, 0x2000, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);<br> if (p == MAP_FAILED) err(1, "mmap");<br> p[0x1000] = 'X';<br> if (madvise(&amp;p[0x1000], 0x1000, MADV_DONTNEED)) err(1, "madvise");<br> // that 'X' we just wrote... is it gone?<br> // nope, let's bring it back!<br> printf("p[0x1000]='%c'\n", p[0x1000]);<br>}</p>