frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Mesh LLM: distributed AI computing on iroh

https://www.iroh.computer/blog/mesh-llm
139•tionis•5h ago•32 comments

We Know Simple Fluids Can Flow. Turns Out, Some Can Fracture

https://www.quantamagazine.org/we-know-simple-fluids-can-flow-turns-out-some-can-fracture-20260710/
25•Anon84•1h ago•4 comments

A pure scheme web programming tool

https://goeteia.dev
30•guenchi•2h ago•13 comments

Show HN: Ant – A JavaScript runtime and ecosystem

https://antjs.org
204•theMackabu•7h ago•86 comments

RISCBoy is an open-source portable games console, designed from scratch

https://github.com/Wren6991/RISCBoy
75•mariuz•5h ago•17 comments

I Did Not Kill Stanley Lieber: How to Draw (With 9front)

https://triapul.cz/automa/i_did_not_kill_stanley_lieber
23•c-c-c-c-c•2d ago•3 comments

The Energetic Costs of Cellular Computation (2012)

https://arxiv.org/abs/1203.5426
9•lioeters•1h ago•1 comments

A dock that wakes up reliably

https://fabiensanglard.net/tb4/index.html
39•ingve•3h ago•31 comments

Nvidia, CoreWeave, and Nebius: Inside the Circular Financing of the GPU Boom

https://io-fund.com/ai-stocks/nvidia-coreweave-nebius-circular-financing-gpu-boom
181•adletbalzhanov•10h ago•62 comments

A Erlang style pure Scheme Webserver and further

https://igropyr.com
12•guenchi•2h ago•1 comments

What xAI's Grok Build CLI Actually Sends to xAI

https://gist.github.com/cereblab/dc9a40bc26120f4540e4e09b75ffb547
97•jhoho•2h ago•50 comments

Billions of Sketches Reveal Hidden Cultural Variation in Human Concepts

https://arxiv.org/abs/2607.07267
63•Anon84•2d ago•8 comments

We scaled PgBouncer to 4x throughput

https://clickhouse.com/blog/pgbouncer-clickhouse-managed-postgres
186•saisrirampur•12h ago•38 comments

UPI: Anatomy of a Payment Transaction

https://timeseriesofindia.com/economy/reads/upi-architecture/
121•prtk25•11h ago•45 comments

Long Covid May Physically Damage the Nerves That Control the Stomach

https://www.ijidonline.com/article/S1201-9712(26)00608-9/fulltext
62•thenerdhead•3h ago•33 comments

Show HN: Quantum-Qec / Matrix-Free Quantum Homeostatic Engine(Blueprint)

https://github.com/PJHkorea/quantum-mesh-qec
3•PJHkorea•1h ago•2 comments

The early History of the Singular Value Decomposition (1993) [pdf]

https://www.math.ucdavis.edu/~saito/courses/229A/stewart-svd.pdf
99•wolfi1•12h ago•60 comments

Jellyfish Undersea Roundabout

https://visitfaroeislands.com/en/plan-your-stay/getting-around/world-first-under-sea-roundabout
7•hydrogen7800•3d ago•0 comments

An agent in 100 lines of Lisp

https://thebeach.dev/posts/lisp-agent/
49•jamiebeach•4d ago•1 comments

Prefer strict tables in SQLite

https://evanhahn.com/prefer-strict-tables-in-sqlite/
236•ingve•10h ago•117 comments

Biff.graph: structure your Clojure codebase as a queryable graph

https://github.com/jacobobryant/biff/tree/v2.x/libs/graph
92•jacobobryant•4d ago•9 comments

Show HN: Learn by rebuilding Redis, Git, a database from scratch

https://shipthatcode.com
137•acley•14h ago•39 comments

Doctors die. It's not like the rest of us, but it should be (2016)

https://archive.cancerworld.net/featured/how-doctors-die/
97•downbad_•4h ago•59 comments

Optimization Solver as a Service

https://www.quicopt.com/developer/getting-started/
21•paddi91•3d ago•12 comments

Martha Lillard, last US polio patient using iron lung, dies at 78 in Oklahoma

https://abcnews.com/US/wireStory/martha-lillard-us-polio-patient-iron-lung-dies-134668491
42•daniel_iversen•3h ago•6 comments

Show HN: Sqlsure – deterministic semantic checks for AI-generated SQL

https://github.com/sqlsure/sqlsure
23•tejusarora•7h ago•3 comments

How to Achieve Pruning When Querying by Non-Partitioned Columns in PostgreSQL

https://hakibenita.com/postgresql-partition-pruning
8•theanonymousone•2d ago•1 comments

Sixtyfour (YC P25) Is Hiring

https://www.ycombinator.com/companies/sixtyfour/jobs/bIbgQkL-operations-associate-data-samples-cu...
1•HPMOR•10h ago

ZeroFS vs. Amazon S3 Files

https://www.zerofs.net/blog/zerofs-vs-aws-s3-files/
68•cbrewster•9h ago•16 comments

Show HN: Orbit – AR satellite tracker, watch 15k+ objects

https://nagylukas.github.io/orbit.html
64•lukas9•11h ago•17 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.