frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Things to know when you get cancer

https://jjmaxwell4.com/writing/things-to-know-when-you-get-cancer/
1299•jjmaxwell4•13h ago•321 comments

Wanted to download an ISO, ended up writing a kernel exploit

https://blog.dfb.sh/blog/eap770-root-for-two-zeros/
45•0xdeafbeef•1d ago•18 comments

Creating a Garmin "MCP"

https://jackantico.io/garmin-mcp
21•ricotico060•1d ago•18 comments

OpenCode 2.0

https://anoma.ly/notes/opencode-2-0/
583•gmays•11h ago•225 comments

Tiny Little Office

https://tinylittleoffice.com/
399•donohoe•10h ago•60 comments

LFM2.5-24B-A2B: Built for fast on-device agents

https://www.liquid.ai/blog/lfm2-5-24b-a2b
200•gmays•8h ago•44 comments

Do dentists know what they're doing?

https://mapwriting.substack.com/p/dentists
671•doitLP•3d ago•480 comments

Show HN: Indigene – Native plants for where you stand

https://indigene.app/
13•olivierlacan•2d ago•1 comments

Catch a Bird – I made it for my own sanity

https://catchabird.com
148•eduardsik•2d ago•33 comments

Americans' social activity has steeply declined in the past 30 years

https://www.dataforprogress.org/blog/2026/9/29/americans-social-activity-has-steeply-declined-in-...
384•hubraumhugo•16h ago•359 comments

Donaldson Futuro House in Idyllwild, California, USA

https://www.wowhaus.co.uk/2026/10/12/donaldson-futuro-house-in-idyllwild-california-usa/
43•rmason•1d ago•14 comments

It took me nine years to hack my Xbox 360

https://kennedn.com/blog/posts/glitching/
77•kennedn•1d ago•18 comments

Aidlc: Adaptive workflow steering rules for AI coding agents

https://github.com/awslabs/aidlc-workflows
4•pramodbiligiri•1h ago•0 comments

The Toftwood Male Voice Choir: A Mystery Pressed in Vinyl

https://ei3lh.eu/2026/10/11/the-toftwood-male-voice-choir-a-mystery-pressed-in-vinyl/
33•austinallegro•3d ago•1 comments

Sticky alpine flower confirms Darwin's 150-year-old carnivorous plant prediction

https://phys.org/news/2026-08-sticky-alpine-darwin-year-carnivorous.html
20•maxall4•2d ago•6 comments

The Double Headed Stack Allocator

https://blog.demofox.org/2026/10/03/the-double-headed-stack-allocator/
61•g0xA52A2A•6h ago•15 comments

Better HTTP/1 connection reuse in Go 1.27

https://go.dev/blog/http-connection-reuse
249•allddd•16h ago•36 comments

Your C is not standard C

https://sebsite.pw/w/20261012-notstdc.html
82•dverlaeckt80•1d ago•46 comments

Show HN: Ito – Build Terminal UIs in Lua

https://uji.sh/ito/
16•cat-whisperer•10h ago•4 comments

David Rudnick on "borderline impossible" process of designing Arsenal typeface

https://www.itsnicethat.com/features/david-rudnick-johnnie-campbell-arsenal-rocastle-typeface-gra...
20•droidjj•2d ago•5 comments

Show HN: Flipflop, Iroh-powered persistent tunnels for filesharing

https://github.com/andunieee/flipflop
30•andunie•4h ago•10 comments

Why is every rationalist blog post way too long?

https://alexwennerberg.com/blog/2026-10-13-long.html
342•epestr•1d ago•284 comments

We’re releasing Jev 1.14.0 along with experimental features for dreamers

https://typesafe.ai/blog/jev-1-14
280•emschwartz•11h ago•90 comments

Show HN: Petal, open-source CoScreen/ScreenHero finally free

https://petal.live/
162•thedracle•14h ago•38 comments

Containment and monitoring failures are to blame for AI hacking reports: experts

https://www.csoonline.com/article/4234854/ai-agents-arent-going-rogue-frontier-labs-are-skipping-...
890•latexr•15h ago•522 comments

AI was great until it was not

https://thetheorygirlie.substack.com/p/ai-was-great-until-it-was-not
5•JohnHammersley•29m ago•0 comments

Ask HN: CAD for wood working with LLM support?

71•reacharavindh•2d ago•62 comments

How Amazon pushes up prices all across the Internet

https://www.not-ship.com/how-amazon-pushes-up-prices-all-across-the-internet/
819•sighborg•23h ago•637 comments

Fancy Curl Sites

https://nytpu.com/gemlog/2026-03-18
126•adunk•13h ago•24 comments

Phloem: Git history grown like a slime mold

https://phloem.stemdeck.app/
113•thclpr•2d ago•22 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.