frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Sleeper Shells: Attackers Are Planting Dormant Backdoors in Ivanti EPMM

https://defusedcyber.com/ivanti-epmm-sleeper-shells-403jsp
56•waihtis•1h ago•16 comments

Thoughts on Generating C

https://wingolog.org/archives/2026/02/09/six-thoughts-on-generating-c
99•ingve•2h ago•12 comments

UEFI Bindings for JavaScript

https://codeberg.org/smnx/promethee
111•ananas-dev•2h ago•62 comments

Why Is the Sky Blue?

https://explainers.blog/posts/why-is-the-sky-blue/
15•udit99•1h ago•2 comments

Show HN: Algorithmically Finding the Longest Line of Sight on Earth

https://alltheviews.world
246•tombh•6h ago•96 comments

Long-Sought Proof Tames Some of Math's Unruliest Equations

https://www.quantamagazine.org/long-sought-proof-tames-some-of-maths-unruliest-equations-20260206/
33•ibobev•2h ago•2 comments

It's not you; GitHub is down again

https://www.githubstatus.com/incidents/54hndjxft5bx
80•MattIPv4•34m ago•47 comments

Converting a $3.88 analog clock from Walmart into a ESP8266-based Wi-Fi clock

https://github.com/jim11662418/ESP8266_WiFi_Analog_Clock
3•tokyobreakfast•20m ago•0 comments

GitHub Is Down

https://github.com/
184•albelfio•31m ago•99 comments

AT&T, Verizon blocking release of Salt Typhoon security assessment reports

https://www.reuters.com/business/media-telecom/senator-says-att-verizon-blocking-release-salt-typ...
101•redman25•2h ago•18 comments

Medieval Monks Wrote over Ancient Star Catalog – Particle Accel Reveals Original

https://www.smithsonianmag.com/smart-news/medieval-monks-wrote-over-a-copy-of-an-ancient-star-cat...
15•bookofjoe•5d ago•0 comments

Art of Roads in Games

https://sandboxspirit.com/blog/art-of-roads-in-games/
507•linolevan•19h ago•162 comments

Vouch

https://github.com/mitchellh/vouch
987•chwtutha•1d ago•430 comments

Like Game-of-Life, but on Growing Graphs, with WASM and WebGL

https://znah.net/graphs/
55•znah•1d ago•9 comments

Humans peak in midlife: A combined cognitive and personality trait perspective

https://www.sciencedirect.com/science/article/pii/S0160289625000649
60•Brajeshwar•2h ago•18 comments

Hong Kong pro-democracy tycoon Jimmy Lai gets 20 years' jail

https://www.bbc.com/news/articles/c8d5pl34vv0o
117•tartoran•1h ago•70 comments

AirPods Pro 4 Could Feature Cameras to 'See Around You'

https://www.macrumors.com/2026/02/09/airpods-pro-4-could-feature-cameras-to-see-around-you/
17•geox•50m ago•29 comments

Roman industrial hub discovered on banks of River Wear

https://www.durham.ac.uk/news-events/latest-news/2026/01/roman-industrial-hub-discovered-on-banks...
49•andsoitis•4d ago•8 comments

Nobody knows how the whole system works

https://surfingcomplexity.blog/2026/02/08/nobody-knows-how-the-whole-system-works/
156•azhenley•11h ago•118 comments

Show HN: Browse Internet Infrastructure

https://www.wirewiki.com
92•pul•4h ago•15 comments

Show HN: Printable Classics – Free printable classic books for hobby bookbinders

https://printableclassics.com
32•bookman10•4h ago•10 comments

Matrix messaging gaining ground in government IT

https://www.theregister.com/2026/02/09/matrix_element_secure_chat/
156•rbanffy•4h ago•120 comments

Offpunk 3.0

https://ploum.net/2026-02-09-offpunk3.html
131•todsacerdoti•6h ago•27 comments

LispE: Lisp Interpreter with Pattern Programming and Lazy Evaluation

https://github.com/naver/lispe
88•PaulHoule•4d ago•16 comments

Show HN: Minimal NIST/OWASP-compliant auth implementation for Cloudflare Workers

https://github.com/vhscom/private-landing
28•vhsdev•5h ago•8 comments

Tessellation Kit (2016)

https://sciencevsmagic.net/tes/#0.5.0.1.aaaaaaaaa
39•surprisetalk•5d ago•3 comments

Show HN: A custom font that displays Cistercian numerals using ligatures

https://bobbiec.github.io/cistercian-font.html
144•bobbiechen•18h ago•33 comments

Every book recommended on the Odd Lots Discord

https://odd-lots-books.netlify.app/
152•muggermuch•17h ago•61 comments

AI Doesn't Reduce Work–It Intensifies It

https://hbr.org/2026/02/ai-doesnt-reduce-work-it-intensifies-it
147•swolpers•2h ago•107 comments

Show HN: I created a Mars colony RPG based on Kim Stanley Robinson’s Mars books

https://underhillgame.com/
278•ariaalam•23h ago•100 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•9mo ago

Comments

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