frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Someone Bought 30 WordPress Plugins and Planted a Backdoor in All of Them

https://anchor.host/someone-bought-30-wordpress-plugins-and-planted-a-backdoor-in-all-of-them/
256•speckx•1h ago•65 comments

Nothing Ever Happens: Polymarket bot that always buys No on non-sports markets

https://github.com/sterlingcrispin/nothing-ever-happens
268•m-hodges•4h ago•105 comments

The Future of Everything Is Lies, I Guess: Safety

https://aphyr.com/posts/417-the-future-of-everything-is-lies-i-guess-safety
183•aphyr•3h ago•87 comments

Show HN: Ithihāsas – a character explorer for Hindu epics, built in a few hours

https://www.ithihasas.in
23•cvrajeesh•39m ago•4 comments

Building a CLI for All of Cloudflare

https://blog.cloudflare.com/cf-cli-local-explorer/
176•soheilpro•4h ago•47 comments

How to make Firefox builds 17% faster

https://blog.farre.se/posts/2026/04/10/caching-webidl-codegen/
22•mbitsnbites•59m ago•0 comments

Servo is now available on crates.io

https://servo.org/blog/2026/04/13/servo-0.1.0-release/
336•ffin•7h ago•115 comments

Tracking down a 25% Regression on LLVM RISC-V

https://blog.kaving.me/blog/tracking-down-a-25-regression-on-llvm-risc-v/
51•luu•23h ago•12 comments

Make Tmux Pretty and Usable (2024)

https://hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/
227•speckx•5h ago•166 comments

MEMS Array Chip Can Project Video the Size of a Grain of Sand

https://spectrum.ieee.org/mems-photonics
52•bookofjoe•5h ago•21 comments

All elementary functions from a single binary operator

https://arxiv.org/abs/2603.21852
748•pizza•18h ago•225 comments

Visualizing CPU Pipelining (2024)

https://timmastny.com/blog/visualizing-cpu-pipelining/
7•flipacholas•1h ago•1 comments

Initial mainline video capture and camera support for Rockchip RK3588

https://www.collabora.com/news-and-blog/news-and-events/mainline-video-capture-and-camera-support...
56•mfilion•6h ago•14 comments

Microsoft isn't removing Copilot from Windows 11, it's just renaming it

https://www.neowin.net/opinions/microsoft-isnt-removing-copilot-from-windows-11-its-just-renaming...
243•bundie•6h ago•158 comments

The Looming College-Enrollment Death Spiral

https://www.theatlantic.com/ideas/2026/04/college-enrollment-demographic-cliff/686750/
15•JumpCrisscross•31m ago•3 comments

Your Startup Is Probably Dead on Arrival

https://steveblank.com/2026/03/17/your-startup-is-probably-dead-on-arrival/
38•tie-in•2d ago•25 comments

US appeals court declares 158-year-old home distilling ban unconstitutional

https://nypost.com/2026/04/11/us-news/us-appeals-court-declares-158-year-old-home-distilling-ban-...
257•t-3•6h ago•189 comments

Michigan 'digital age' bills pulled after privacy concerns raised

https://www.thecentersquare.com/michigan/article_7ca4e268-4a68-42fb-9042-f9d8604ebd7f.html
175•iamnothere•7h ago•85 comments

B-trees and database indexes (2024)

https://planetscale.com/blog/btrees-and-database-indexes
9•tosh•2h ago•2 comments

Who's Been Impersonating This ProPublica Reporter?

https://www.propublica.org/article/impersonating-propublica-reporter
61•hn_acker•3h ago•0 comments

The economics of software teams: Why most engineering orgs are flying blind

https://www.viktorcessan.com/the-economics-of-software-teams/
366•kiyanwang•14h ago•221 comments

Evaluation of Claude Mythos Preview's cyber capabilities

https://www.aisi.gov.uk/blog/our-evaluation-of-claude-mythos-previews-cyber-capabilities
31•dgavey•1h ago•15 comments

DIY Soft Drinks

https://blinry.org/diy-soft-drinks/
660•_Microft•1d ago•194 comments

Taking on CUDA with ROCm: 'One Step After Another'

https://www.eetimes.com/taking-on-cuda-with-rocm-one-step-after-another/
247•mindcrime•21h ago•185 comments

We May Be Living Through the Most Consequential Hundred Days in Cyber History

https://ringmast4r.substack.com/p/we-may-be-living-through-the-most
196•laurex•4h ago•113 comments

Bring Back Idiomatic Design (2023)

https://essays.johnloeber.com/p/4-bring-back-idiomatic-design
655•phil294•1d ago•359 comments

Show HN: boringBar – a taskbar-style dock replacement for macOS

https://boringbar.app/
485•a-ve•1d ago•275 comments

Most people can't juggle one ball

https://www.lesswrong.com/posts/jTGbKKGqs5EdyYoRc/most-people-can-t-juggle-one-ball
481•surprisetalk•4d ago•167 comments

Android now stops you sharing your location in photos

https://shkspr.mobi/blog/2026/04/android-now-stops-you-sharing-your-location-in-photos/
280•edent•8h ago•253 comments

Ask HN: What Are You Working On? (April 2026)

306•david927•1d ago•1026 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•11mo ago

Comments

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