frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Ntsc-rs – open-source video emulation of analog TV and VHS artifacts

https://ntsc.rs/
216•gregsadetsky•4h ago•40 comments

Meta confirms 1000s of Instagram accounts were hacked by abusing its AI chatbot

https://this.weekinsecurity.com/meta-confirms-thousands-of-instagram-accounts-were-hacked-by-abus...
331•speckx•5h ago•121 comments

Moving beyond fork() + exec()

https://lwn.net/SubscriberLink/1076018/16f01bbbb8e0d1f0/
221•jwilk•9h ago•243 comments

Zeroserve: A zero-config web server you can script with eBPF

https://su3.io/posts/introducing-zeroserve
175•losfair•8h ago•44 comments

Home alone: Remote work, isolation, and mental health

https://www.science.org/doi/10.1126/science.aec7671
102•speckx•3h ago•96 comments

Nvidia is proposing a beast of a CPU system for Windows PCs

https://twitter.com/lemire/status/2062880075117113739
217•tosh•10h ago•397 comments

New U.S. college grads now have higher unemployment than the average worker

https://www.randalolson.com/2026/06/04/recent-grad-unemployment-flip/
104•davidbarker•3h ago•79 comments

You Can Run

https://magazine.atavist.com/2026/mccann-cocaine-fugitives
90•bryanrasmussen•7h ago•41 comments

Sem: New primitive for code understanding – not LSPs, but entities on top of Git

https://ataraxy-labs.github.io/sem/
27•rohanucla•3h ago•13 comments

Computex 2026: Are We Heading for the Agentic PC Era Yet?

https://www.eetimes.com/computex-2026-are-we-heading-for-the-agentic-pc-era-yet/
18•rbanffy•3h ago•18 comments

PyTorch Custom Operation

https://leimao.github.io/blog/PyTorch-Custom-Operation/
15•eigenBasis•5d ago•2 comments

Pokemon Emerald Ported to WebAssembly (100k FPS)

https://pokeemerald.com/
255•tripplyons•12h ago•70 comments

Show HN: Infinite canvas notes in the non-Euclidean Poincaré disk

https://uonr.github.io/poincake/
107•uonr•4d ago•18 comments

Pentagon raised threat of Israeli spying on U.S. to highest level, sources say

https://www.nbcnews.com/politics/national-security/pentagon-raised-threat-israeli-spying-us-highe...
356•MilnerRoute•5h ago•243 comments

Google to pay SpaceX $920M a month for compute capacity at xAI data centers

https://www.cnbc.com/2026/06/05/google-to-pay-spacex-920-million-a-month-for-xai-compute-capacity...
113•toephu2•1d ago•683 comments

Benchmarks in Leipzig

https://arxiv.org/abs/2606.05818
120•root-parent•9h ago•44 comments

The new bibliomaniacs

https://engelsbergideas.com/notebook/the-new-bibliomaniacs/
60•RickJWagner•11h ago•50 comments

Ask HN: What was your "oh shit" moment with GenAI?

532•andrehacker•1d ago•931 comments

Static Devirtualization of Themida

https://back.engineering/blog/09/05/2026/
15•homarp•4d ago•1 comments

Running Python code in a sandbox with MicroPython and WASM

https://simonwillison.net/2026/Jun/6/micropython-in-a-sandbox/
70•theanonymousone•9h ago•20 comments

Motorola effectively bricked its entire line of WiFi routers without explanation

https://mashable.com/tech/motorola-wifi-routers-stop-working-motosync-plus-app-down
39•thisislife2•8h ago•10 comments

S&P 500 rejects SpaceX, also blocking entry for OpenAI and Anthropic

https://arstechnica.com/tech-policy/2026/06/sp-500-blocks-fast-spacex-entry-wont-waive-rule-for-u...
1334•maltalex•19h ago•462 comments

How to make firecracker faster to start Chromium in < 20ms

https://www.kernel.sh/blog/firecracker-faster
4•juecd•1d ago•3 comments

WoofWare.PawPrint, a Deterministic .NET Runtime

https://www.patrickstevens.co.uk/posts/2026-06-04-announcing-woofware-pawprint/
47•Smaug123•2d ago•14 comments

Building Rust Procedural Macros from the Grounds Up

https://www.learnix-os.com/ch02-03-implementing-the-bitfields-proc-macro.html
80•Sagi21805•6d ago•15 comments

Summer of '85: DOSBOS is rejected by ANALOG Computing

https://www.goto10retro.com/p/summer-of-85-dosbos-is-rejected-by
48•ibobev•2d ago•11 comments

Mbodi AI (YC P25) Is Hiring Founding Machine Learning Engineer (Robotics)

https://www.ycombinator.com/companies/mbodi-ai/jobs/WYAcNkX-founding-machine-learning-engineer
1•chitianhao•11h ago

Ask HN: Why is the HN crowd so anti-AI?

360•Ekami•21h ago•603 comments

Trees to Flows and Back: Unifying Decision Trees and Diffusion Models

https://arxiv.org/abs/2605.00414
43•rsn243•10h ago•8 comments

The intracies of modern camera lens repair (2024)

https://salvagedcircuitry.com/sigma-45mm.html
240•transistor-man•23h ago•84 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•1y ago

Comments

wahern•1y 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•1y 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•1y ago
What language is that? Is it available everywhere (everywhere) C is?
mitthrowaway2•1y 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•1y 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•1y 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•1y ago
Learning such a language doesn’t mean I can use it.
o11c•1y 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•1y 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•1y 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•1y ago
This reminds me of the days when Boost was a thing. It was full of tricks like this.
usrnm•1y ago
It still is a thing, though.
cperciva•1y 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•1y 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.