frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

GUIs should be fully keyboard-driven

https://ckardaris.com/blog/2026/08/28/keyboard-driven-guis.html
562•ckardaris•8h ago•284 comments

Boot a Virtual iPhone via Apple's Virtualization.framework

https://github.com/Lakr233/vphone-cli
18•hentrep•1h ago•5 comments

Htmx 4.0

https://four.htmx.org/announcements/2026-08-28-htmx-4.0.0-is-released
486•rmsaksida•10h ago•120 comments

Just the rumour of a bug is enough to find an exploit these days

https://anil.recoil.org/notes/rumour-is-the-exploit
242•avsm•8h ago•88 comments

U.S. sanctions against the A/I Collective

https://www.inventati.org/
454•exiguus•11h ago•421 comments

Inception-style curved map for turn-by-turn directions

https://www.orbify.eu/demo/
407•smoser•11h ago•137 comments

Does the Sumerian King List Align with Paleoclimate Events?

https://www.vectorian.be/articles/2026-06-07/sumerian-king-list-paleoclimate-alignment-explorer/
4•dev_l1x_be•23m ago•0 comments

Identifying fake cosmetics using AI

https://groverlab.org/hnbfpr/2026-08-26-ai-counterfeit-cosmetics.html
14•wgrover•1h ago•5 comments

Curvature Beziers: Improving on a timeless recipe

https://acko.net/blog/curvature-beziers/
67•leephillips•4d ago•11 comments

A Japanese shrine has recorded one lake's ice for 583 years, as a divination

https://jivx.com/omiwatari
6•momentmaker•3d ago•0 comments

Judge rules Trump administration’s blacklisting of Anthropic was illegal

https://www.nytimes.com/2026/08/27/technology/anthropic-government-blacklisting-ruling.html
497•jbegley•22h ago•367 comments

The Twelve-Factor App (2025)

https://12factor.net/
213•jxmorris12•1d ago•111 comments

Processing in Memory: DRAM Is About to Do Math

https://ben3d.ca/blog/processing-in-memory
55•bhouston•2d ago•14 comments

Visual Analysis of Binary Files

https://binvis.io/#/
59•vismit2000•2d ago•14 comments

GLM-5.3 is now open-weight

https://huggingface.co/zai-org/GLM-5.3
565•jeudesprits•8h ago•201 comments

Autonomous Mathematical Discovery in an Open-World Multi-Agent Environment

https://arxiv.org/abs/2608.23691
74•stephenchung•7h ago•16 comments

Show HN: Sesame - a local-first, open-source password manager

https://usesesame.app/
30•d0mkaaa•4h ago•31 comments

Luanti removed from Google Play due to baseless AI copyright notice

https://blog.luanti.org/2026/08/27/luanti-dmca-tracer-ai/
429•miniBill•17h ago•132 comments

Hilariously fast volume computation with the divergence theorem (2018)

https://alyssarosenzweig.ca/blog/hilariously-fast-volume-computation-with-the-divergence-theorem....
245•luu•15h ago•65 comments

Attimet (YC F24) Is Hiring Members of Technical Staff – Engineering and Research

https://www.ycombinator.com/companies/attimet/jobs/6btZFDg-member-of-technical-staff-engineering
1•kbanothu•7h ago

Verschlimmbesserung: The Word Your Software Updates Need

https://geekyschmidt.com/post/2026-08-25-verschlimmbesserung/
101•speckx•9h ago•66 comments

Sloc Cloc and Code 4.0 (scc) – Finding the files that need the most attention

https://boyter.org/posts/sloc-cloc-code-hotspots-finding-files-that-need-attention/
23•boyter•4d ago•0 comments

Stopping the smart TV from being used against you

https://www.s-config.com/stopping-a-smart-tv-from-being-used-against-you/
136•speckx•3h ago•104 comments

Migrating to HTTPX2

https://github.com/openai/openai-python/blob/main/httpx2.md
181•tosh•12h ago•79 comments

Global demand for sand spawned a worldwide boom in illegal mining (2015)

https://www.wired.com/2015/03/illegal-sand-mining/
52•EndXA•3d ago•24 comments

State of the Map 2026

https://2026.stateofthemap.org/
136•lode•10h ago•50 comments

Get your Windows license refund

https://en.refund4freedom.org/
644•smartmic•10h ago•263 comments

An investigation into the state of corvid–human relations

https://www.audubon.org/magazine/are-crows-really-our-friends
106•speckx•11h ago•63 comments

Some conservationists are helping to restore Africa’s wild dog populations

https://www.smithsonianmag.com/science-nature/africa-wild-dogs-most-hated-carnivores-continent-he...
67•speckx•9h ago•28 comments

The ArtQrCode a twist on the classic black and white Quick Response Code

https://art-qrcode.com/
6•Bluestein•3d ago•0 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.