frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Pirating the Pirates

https://mubi.com/en/notebook/posts/pirating-the-pirates
95•piotrgrabowski•1h ago•18 comments

13 Months Sober (2025)

https://www.bobbytables.io/p/13-months-sober
45•btables•1h ago•36 comments

Hijacking the PS5's RTMP Stream

https://yashgarg.dev/posts/hijacking-ps5-rtmp-stream/
44•ibobev•2h ago•3 comments

Parley: Federated, decentralised chat that speaks plain IRC

https://git.mills.io/prologic/parley
237•davidcollantes•7h ago•113 comments

Show HN: HN.watch – Videos of all Hacker News posts

https://hn.watch/
12•mrborgen•2h ago•4 comments

What Heraldry and Mon Can Teach Us About Building Visual-Identity Generators

https://benovermyer.com/blog/2026/09/japanese-vs-western-heraldry/
36•bovermyer•2h ago•11 comments

The problem is not AI code, but not knowing about system architecture or intent

https://www.ssp.sh/brain/the-problem-is-not-the-ai-code-but-nobody-knows-anything-anymore/
241•zazuke•1h ago•152 comments

MongoDB CEO resigns to join Meta

https://www.reuters.com/technology/mongodb-ceo-desai-steps-down-lead-metas-enterprise-platform-20...
125•diek•2h ago•120 comments

Cf: The Agentic CLI for the Cloudflare API

https://blog.cloudflare.com/cloudflare-cf-cli-launch/
17•macleos•2h ago•2 comments

Coding Is Not Solved

https://blog.alexewerlof.com/p/coding-is-not-solved
297•firstSpeaker•3h ago•306 comments

37,500 border drawings: a map of the world as people remember it

https://www.habibicode.org/thedrawnworld
136•nicocarsui•9h ago•31 comments

Show HN: PaperMono, e-ink fridge magnet shopping list with mobile web page

https://github.com/seamusc/papermono-shopping-list
84•seamus_c•7h ago•36 comments

What Would a Serious AI Product Look Like?

https://blog.glyph.im/2026/09/serious-ai-product.html
47•lumpa•6h ago•19 comments

Footguns with Postgres "at time zone 'UTC'"

https://bookofrevenue.com/blog/6ab81e9a97a13f0001f7e4e1/postgres-at-time-zone-u-does-not-do-what-...
132•birdculture•1d ago•73 comments

Owed a billion dollars in Nvidia stock

https://colo.to/nvidia-stock-narrative.html
989•Eric_Gullichsen•15h ago•420 comments

Kids turned low-traffic NPR Spotify comments into a secret group chat

https://www.thisamericanlife.org/897/transcript
103•simonpure•2h ago•75 comments

Show HN: Hntui – A TUI for Hacker News

https://github.com/ahmd-sh/hntui
96•ahmd-sh•5h ago•44 comments

Ember-1

https://fireworks.ai/blog/ember-1
558•gmays•1d ago•240 comments

Show HN: Free alternative to graphics design giants

https://scissor.studio/
53•sia_xi•8h ago•17 comments

When did Google get so weird?

https://sancho.bearblog.dev/google-weird/
1647•sancho-panza•21h ago•898 comments

Nissan's third generation e-POWER powertrain

https://www.nissan-global.com/EN/INNOVATION/TECHNOLOGY/ARCHIVE/E_POWER_GEN3/
137•mroche•15h ago•307 comments

Driver Ticketed for No Insurance Just Because Flock (YC 2017) Said She Didn't

https://www.techdirt.com/2026/09/28/driver-ticketed-for-no-insurance-despite-having-insurance-jus...
11•HotGarbage•37m ago•0 comments

How Pew Research Center is – and is not – using AI in our work

https://www.pewresearch.org/decoded/2026/09/28/how-pew-research-center-is-and-is-not-using-ai-in-...
7•hn_acker•27m ago•1 comments

Solving a corn puzzle with CP-SAT

https://thill.me/2026/07/16/corn-puzzle-sat-solver.html
5•luu•20h ago•2 comments

Thinking fast and slow in AI: The role of metacognition (2021)

https://arxiv.org/abs/2110.01834
163•teleforce•14h ago•65 comments

Self-Hosting on the Dark Web

https://david.alvarezrosa.com/posts/self-hosting-on-the-dark-web/
318•mooreds•21h ago•106 comments

Malleable software: Restoring user agency in a world of locked-down apps (2025)

https://www.inkandswitch.com/essay/malleable-software/
142•evakhoury•22h ago•69 comments

Alan Kay's answer to “Did the ENIAC have a BIOS”?

https://www.quora.com/Did-the-ENIAC-have-a-BIOS/answer/Alan-Kay-11
175•midnightfish•21h ago•61 comments

Guitar amp and effects pedal built on the Waveshare ESP32-S3-Touch-AMOLED-2.06

https://github.com/dashersw/coyopedal
147•arbayi•2d ago•73 comments

Functional Mechanical Sympathy [video]

https://www.youtube.com/watch?v=jSHmDnUZCm8
61•surprisetalk•2d ago•11 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.