frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

SDF Public Access Unix System

https://sdf.org/?ssh
53•neehao•1d ago•16 comments

Stripe's Payment APIs: the first 10 years (2020)

https://stripe.dev/blog/payment-api-design
33•tibbar•3h ago•8 comments

Ben Lerner's Big Feelings

https://www.vulture.com/article/ben-lerner-transcription-interview.html
22•prismatic•4d ago•5 comments

Up to 8M Bees Are Living in an Underground Network Beneath This Cemetery

https://www.discovermagazine.com/up-to-8-million-bees-are-living-in-an-underground-network-beneat...
27•janandonly•2d ago•2 comments

Vercel April 2026 security incident

https://www.bleepingcomputer.com/news/security/vercel-confirms-breach-as-hackers-claim-to-be-sell...
725•colesantiago•18h ago•414 comments

Zero-copy protobuf and ConnectRPC for Rust

https://medium.com/@iainmcgin/zero-copy-protobuf-and-connectrpc-for-rust-69bda8ac0f02
44•PaulHoule•3d ago•13 comments

Claude Token Counter, now with model comparisons

https://simonwillison.net/2026/Apr/20/claude-token-counts/
92•twapi•7h ago•31 comments

OpenClaw isn't fooling me. I remember MS-DOS

https://www.flyingpenguin.com/build-an-openclaw-free-secure-always-on-local-ai-agent/
3•feigewalnuss•41m ago•0 comments

A Brief History of Fish Sauce

https://www.legalnomads.com/fish-sauce/
173•vinhnx•23h ago•69 comments

Monumental ship burial beneath ancient Norwegian mound predates the Viking Age

https://phys.org/news/2026-04-monumental-ship-burial-beneath-ancient.html
49•pseudolus•2d ago•14 comments

Stop trying to engineer your way out of listening to people

https://ashley.rolfmore.com/stop-trying-to-engineer-your-way-out-of-listening-to-people/
192•walterbell•12h ago•78 comments

The Bromine Chokepoint

https://warontherocks.com/cogs-of-war/the-bromine-chokepoint-how-strife-in-the-middle-east-could-...
197•crescit_eundo•14h ago•100 comments

Turtle WoW classic server announces shutdown after Blizzard wins injunction

https://www.pcgamer.com/games/world-of-warcraft/turtle-wow-classic-server-announces-shutdown-afte...
216•Brajeshwar•16h ago•185 comments

Mechanical Keyboard Sounds – A listening Museum

https://sheets.works/data-viz/keyboard-sounds
114•akashwadhwani35•4d ago•35 comments

Knitout and Kniterate 3

https://soup.agnescameron.info//2026/04/01/transfers.html
21•surprisetalk•3d ago•0 comments

How Long Poop Stays in Your Body May Impact Your Health, Study Finds

https://www.sciencealert.com/how-long-poop-stays-in-your-body-may-impact-your-health-study-finds
27•mikhael•1h ago•17 comments

Changes in the system prompt between Claude Opus 4.6 and 4.7

https://simonwillison.net/2026/Apr/18/opus-system-prompt/
308•pretext•21h ago•175 comments

A cache-friendly IPv6 LPM with AVX-512 (linearized B+-tree, real BGP benchmarks)

https://github.com/esutcu/planb-lpm
26•debugga•5h ago•8 comments

Swiss AI Initiative (2023)

https://www.swiss-ai.org
64•doener•9h ago•24 comments

Show HN: Run TRELLIS.2 Image-to-3D generation natively on Apple Silicon

https://github.com/shivampkumar/trellis-mac
152•shivampkumar•8h ago•24 comments

Two Motorola Transistors Became the Default NPNs

https://www.allaboutcircuits.com/news/how-two-motorola-transistors-became-the-worlds-default-npns/
18•ChuckMcM•2d ago•7 comments

2,100 Swiss municipalities showing which provider handles their official email

https://mxmap.ch/
172•doener•9h ago•45 comments

The RAM shortage could last years

https://www.theverge.com/ai-artificial-intelligence/914672/the-ram-shortage-could-last-years
282•omer_k•1d ago•317 comments

Scientific datasets are riddled with copy-paste errors

https://www.sciencedetective.org/scientific-datasets-are-riddled-with-copy-paste-errors/
93•jruohonen•13h ago•26 comments

Six Levels of Dark Mode (2024)

https://cssence.com/2024/six-levels-of-dark-mode/
83•Akcium•13h ago•36 comments

I wrote a CHIP-8 emulator in my own programming language

https://github.com/navid-m/chip8emu
69•pizza_man•13h ago•16 comments

Prove you are a robot: CAPTCHAs for agents

https://browser-use.com/posts/prove-you-are-a-robot
98•lukasec•4d ago•45 comments

Nanopass Framework: Clean Compiler Creation Language

https://nanopass.org/
131•NordStreamYacht•4d ago•32 comments

Show HN: Prompt-to-Excalidraw demo with Gemma 4 E2B in the browser (3.1GB)

https://teamchong.github.io/turboquant-wasm/draw.html
128•teamchong•21h ago•48 comments

SPEAKE(a)R: Turn Speakers to Microphones for Fun and Profit [pdf] (2017)

https://www.usenix.org/system/files/conference/woot17/woot17-paper-guri.pdf
176•Eridanus2•23h ago•69 comments
Open in hackernews

Detecting if an expression is constant in C

https://nrk.neocities.org/articles/c-constexpr-macro#detecting-if-an-expression-is-constant-in-c
49•signa11•11mo ago

Comments

wahern•11mo ago
> This works. But both gcc and clang warn about the enum being anonymous... even though that's exactly what I wanted to do. And this cannot be silenced with #pragma since it's a macro, so the warning occurs at the location where the macro is invoked.

You can use _Pragma instead of #pragma. E.g.

  #define C(x) ( \
    _Pragma("clang diagnostic push") \
    _Pragma("clang diagnostic ignored \"-Wvisibility\"") \
    (x) + 0*sizeof(void (*)(enum { tmp = (int)(x) })) \
    _Pragma("clang diagnostic pop") \
  )
EDIT: Alas, GCC is a little pickier about where _Pragma is allowed so you may need to use a statement expression. Also, it seems GCC 14 doesn't have a -W switch that will disable the anonymous enum warning.
pjc50•11mo ago
It's remarkable that people will say that doing this kind of thing is better than learning a language which actually lets you enforce this with the type system.

(or even just insist that users use the version of the language which supports "constexpr"!)

oguz-ismail•11mo ago
What language is that? Is it available everywhere (everywhere) C is?
mitthrowaway2•11mo ago
Indeed, usually if I'm using C these days it's because I only have access to a c compiler for my target platform, or because I'm modifying an existing C codebase.
uecker•11mo ago
I do not think anybody said this. The point is that these macros work for early versions of C. If you need to support early versions of C, learning another language is not a solution. If you don't have to, you can use C23's constexpr.
trealira•11mo ago
C used to seem like a beautiful and simple language to me, but as I used it and learned more about it, it seemed more complex under the surface, and kind of janky as well. It's just utilitarian.
wat10000•11mo ago
Learning such a language doesn’t mean I can use it.
o11c•11mo ago
The problem is that no such language exists.

There are many languages that provide one particular feature that C doesn't provide, but they do this at the cost of excluding numerous other features that C widely relies on.

kjs3•11mo ago
"I have no idea what problem you're trying to solve, what the constraints are, what the use cases might be, what tools are available on the platform, what the job or regulations require, what the skillsets of the people involved are, what the timeline is...but I'm absolutely, unshakably certain that I have a magic bullet that will make all your problems go away."

FTFY.

sleirsgoevy•11mo ago
The Linux kernel has even a way to determine whether the expression is compile-time, WITHOUT aborting compilation in either case.

The trick is this (copied vebratim from Linux):

#define __is_constexpr(x) (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))

Explanation: if x is a constant expression, then multiplying it by zero yields a constant 0, and casting a constant 0 to void* makes a null pointer constant. And the ternary expression, if one of its sides is a null pointer constant, collapses to the type of the other side (thus the type of the returned pointer will be int*, and the sizeof will match). And if x was not constant, then the lefthand side would not be considered a null pointer constant by type inference, the type of the ternary expression will be void*, and the sizeof check will not match.

With a few more clever tricks, it's even possible to implement a compile-time "type ternary expression", like this: TYPE_IF(2 * 2 == 4, int, long). This is left as an exercise for the reader.

amelius•11mo ago
This reminds me of the days when Boost was a thing. It was full of tricks like this.
usrnm•11mo ago
It still is a thing, though.
cperciva•11mo ago
With a few more clever tricks...

I did this with my PARSENUM macro (https://github.com/Tarsnap/libcperciva/blob/master/util/pars...) to parse strings into floating-point, unsigned integer, or signed integer types (and check bounds) using a single interface.

bobbyi•11mo ago
I thought this would work:

#define C(x) (sizeof(char[x]), x)

sizeof is a compile-time operation so x need to be known at compile time.

It didn't work as expected. It turns out there is an exception and the standard says that sizeof is actually calculated at runtime specifically for variable length arrays:

> The sizeof operator yields the size (in bytes) of its operand, which may be an expression or the parenthesized name of a type. The size is determined from the type of the operand. The result is an integer. If the type of the operand is a variable length array type, the operand is evaluated; otherwise, the operand is not evaluated and the result is an integer constant.