frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Phoenix: A modern X server written from scratch in Zig

https://git.dec05eba.com/phoenix/about/
440•snvzz•11h ago•215 comments

Why 'The Global Market' Is an Irresponsible Phrase

https://oswarld.com/eng/insight/251117_Why-the-global-market-Is-an-Irresponsible-Phrase
7•haebom•1h ago•2 comments

Tell HN: Merry Christmas

1274•basilikum•11h ago•312 comments

Self-referencing Page Tables for the x86-Architecture

https://0l.de/blog/2015/01/bachelor-thesis-abstract/
12•stv0g•1h ago•0 comments

Who Watches the Waymos? I do [video]

https://www.youtube.com/watch?v=oYU2hAbx_Fc
175•notgloating•10h ago•52 comments

Ruby 4.0.0

https://www.ruby-lang.org/en/news/2025/12/25/ruby-4-0-0-released/
301•FBISurveillance•6h ago•62 comments

Asterisk AI Voice Agent

https://github.com/hkjarral/Asterisk-AI-Voice-Agent
119•akrulino•11h ago•49 comments

Fabrice Bellard: Biography (2009) [pdf]

https://www.ipaidia.gr/wp-content/uploads/2020/12/117-2020-fabrice-bellard.pdf
277•lioeters•16h ago•80 comments

Show HN: Minimalist editor that lives in browser, stores everything in the URL

https://github.com/antonmedv/textarea
337•medv•14h ago•109 comments

CSRF protection without tokens or hidden form fields

https://blog.miguelgrinberg.com/post/csrf-protection-without-tokens-or-hidden-form-fields
210•adevilinyc•3d ago•65 comments

Handheld PC Community Forums

https://www.hpcfactor.com/forums/category-view.asp
9•walterbell•3d ago•1 comments

JEDEC developing reduced pin count HBM4 standard to enable higher capacity

https://blocksandfiles.com/2025/12/17/jedec-sphbm4/
39•rbanffy•6d ago•1 comments

Quantum Error Correction Goes FOOM

https://algassert.com/post/2503
3•EvgeniyZh•1h ago•0 comments

Show HN: Vibium – Browser automation for AI and humans, by Selenium's creator

https://github.com/VibiumDev/vibium
317•hugs•16h ago•97 comments

Show HN: Exploring Mathematics with Python

https://coe.psu.ac.th/ad/explore/
129•Andrew2565•5d ago•11 comments

Using Vectorize to build an unreasonably good search engine in 160 lines of code

https://blog.partykit.io/posts/using-vectorize-to-build-search/
76•ColinWright•3d ago•21 comments

Fabrice Bellard Releases MicroQuickJS

https://github.com/bellard/mquickjs/blob/main/README.md
1386•Aissen•1d ago•522 comments

Research team digitizes more than 100 years of Canadian infectious disease data

https://news.mcmaster.ca/mcmaster-research-team-digitizes-more-than-100-years-of-canadian-infecti...
116•XzetaU8•6d ago•6 comments

We invited a man into our home at Christmas and he stayed with us for 45 years

https://www.bbc.co.uk/news/articles/cdxwllqz1l0o
5•rajeshrajappan•6m ago•0 comments

Comptime – C# meta-programming with compile-time code generation and evaluation

https://github.com/sebastienros/comptime
92•bj-rn•4d ago•21 comments

The First Photographs of Snowflakes Discover the Groundbreaking Microphotography

https://www.openculture.com/2017/12/the-first-photographs-of-snowflakes.html
3•_____k•6d ago•0 comments

Nvidia buying AI chip startup Groq for about $20B in cash

https://www.cnbc.com/2025/12/24/nvidia-buying-ai-chip-startup-groq-for-about-20-billion-biggest-d...
542•nickrubin•13h ago•310 comments

Prototaxites

https://astrobiology.com/2025/03/ancient-prototaxites-dont-belong-to-any-living-lineage-possibly-...
43•andsoitis•5d ago•4 comments

Free Software Foundation receives historic private donations

https://www.fsf.org/news/free-software-foundation-receives-historic-private-donations
89•pentagrama•5h ago•12 comments

The Next-Gen Mainboard Designed with AmigaOS4 and MorphOS in Mind

https://mirari.vitasys.nl/our-story/
38•todsacerdoti•10h ago•7 comments

The dawn of a world simulator

https://odyssey.ml/the-dawn-of-a-world-simulator
65•olivercameron•4d ago•37 comments

I'm returning my Framework 16

https://yorickpeterse.com/articles/im-returning-my-framework-16/
235•YorickPeterse•21h ago•379 comments

The port I couldn't ship

https://ammil.industries/the-port-i-couldnt-ship/
115•cjlm•6d ago•74 comments

Jingle Bells (Batman Smells): An incomplete festive folk-rhyme taxonomy

https://loreandordure.com/2025/12/16/jingle-bells/
96•helsinkiandrew•3d ago•39 comments

Keystone (YC S25) is hiring engineer #1 to automate coding

https://www.ycombinator.com/companies/keystone/jobs/J3t9XeM-founding-engineer
1•pablo24602•13h ago
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•7mo ago

Comments

wahern•7mo 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•7mo 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•7mo ago
What language is that? Is it available everywhere (everywhere) C is?
mitthrowaway2•7mo 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•7mo 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•7mo 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•7mo ago
Learning such a language doesn’t mean I can use it.
o11c•7mo 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•7mo 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•7mo 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•7mo ago
This reminds me of the days when Boost was a thing. It was full of tricks like this.
usrnm•7mo ago
It still is a thing, though.
cperciva•7mo 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•7mo 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.