frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

EEG shows brain can simultaneous encode two speech streams

https://journals.plos.org/plosbiology/article?id=10.1371/journal.pbio.3003876
52•giuliomagnifico•2h ago•18 comments

How Has Roman Concrete Lasted for Millennia? 1,900-Year-Old Latrine Offers Clues

https://www.smithsonianmag.com/smart-news/how-has-roman-concrete-lasted-for-millennia-a-1900-year...
98•divbzero•4h ago•59 comments

Kimi K3: Open Frontier Intelligence

https://www.kimi.com/blog/kimi-k3
1534•vincent_s•17h ago•922 comments

Pebble Mega Update – July 2026

https://repebble.com/blog/pebble-mega-update-july-2026
81•crazysaem•4h ago•10 comments

An Engineer's Guide to USB Typе-С (2024)

https://www.ti.com/lit/eb/slyy228/slyy228.pdf?ts=1759892558029
141•gregsadetsky•6d ago•4 comments

Microsoft Comic Chat is now open source

https://opensource.microsoft.com/blog/2026/07/16/microsoft-comic-chat-is-now-open-source/
651•jervant•15h ago•144 comments

Starlink from 1984

https://nemanjatrifunovic.substack.com/p/starlink-from-1984
27•ingve•5d ago•3 comments

Decoy Font

https://www.mixfont.com/experiments/decoy-font
525•ray__•15h ago•121 comments

LM Studio Bionic: the AI agent for open models

https://lmstudio.ai/blog/introducing-lm-studio-bionic
233•minimaxir•11h ago•81 comments

GrapheneOS recommended for domestic abuse victims

https://privacypros.com.au/privacy-hub/articles/dv-safe-phone-australia/
120•aussieguy1234•6h ago•92 comments

$100 AI Music Video: Claude Fable 5 vs. GPT-5.6 Sol

https://www.tryai.dev/blog/ai-music-video-arena-claude-vs-gpt-5.6
239•hershyb_•11h ago•299 comments

Solod: Go can be a better C

https://solod.dev
114•koeng•3d ago•44 comments

NotebookLM is now Gemini Notebook

https://blog.google/innovation-and-ai/products/gemini-notebook/notebooklm-gemini-notebook/
298•xnx•15h ago•151 comments

The Little Book of Reinforcement Learning

https://github.com/alxndrTL/little-book-rl/
116•mustaphah•9h ago•14 comments

Old Icons

https://leancrew.com/all-this/2026/07/old-icons/
46•zdw•5d ago•10 comments

M 3.9 Experimental Explosion – 147 Km ENE of Ponce Inlet, Florida

https://earthquake.usgs.gov/earthquakes/eventpage/us7000t13l/executive
59•hnburnsy•7h ago•32 comments

How RCA Victor sold Sound Service to classrooms in 1939

https://pncnmnp.github.io/blogs/rca-victor-education.html
25•pncnmnp•1w ago•10 comments

Immersive Linear Algebra Book with Interactive Figures (2015)

https://immersivemath.com/ila/
210•srean•16h ago•26 comments

Detecting LLM-Generated Texts with “Classical” Machine Learning

https://blog.lyc8503.net/en/post/llm-classifier/
190•uneven9434•15h ago•133 comments

Helium escaping from atmosphere of nearby rocky exoplanet in a habitable zone

https://www.science.org/doi/10.1126/science.aea9708
98•anyonecancode•11h ago•27 comments

Mathematics of Data Science

https://arxiv.org/abs/2607.11938
144•Anon84•11h ago•5 comments

UIUC AI Teaching Assistant

https://github.com/Center-for-AI-Innovation/ai-teaching-assistant-uiuc
16•teleforce•5h ago•0 comments

In Praise of Exhaustive Destructuring

https://antoine.vandecreme.net/blog/exhaustive-destructuring-praise/
12•avandecreme•4d ago•3 comments

'Likweli': A new monkey species discovered in the Congo Basin

https://news.yale.edu/2026/07/15/meet-likweli-new-monkey-species-discovered-congo-basin
75•gmays•10h ago•17 comments

The human-in-the-loop is tired

https://pydantic.dev/articles/the-human-in-the-loop-is-tired
173•haritha1313•7h ago•91 comments

CD sales growth outpaced vinyl in the first half of 2026

https://consequence.net/2026/07/the-cd-revival-is-getting-hard-to-ignore/
94•speckx•14h ago•107 comments

Show HN: Clx – Compile Lua to Native Executables Through C++20

https://github.com/samyeyo/clx
112•_samt_•5d ago•12 comments

Ring-Zero: Scaling Zero RL to a Trillion Parameters for Emergent Reasoning

https://arxiv.org/abs/2607.12395
50•binyu•10h ago•18 comments

The LLM Critics Are Right. I Use LLMs Anyway

https://www.theocharis.dev/blog/llm-critics-are-right-i-use-llms-anyway/
215•JeremyTheo•20h ago•225 comments

How to Train a Gen AI Kick Drum Model on Your Old Linux Desktop with 6GB VRAM

https://www.zhinit.dev/blog/training-a-kick-drum-diffusion-model
124•zhinit•16h ago•60 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.