frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

OpenPrinter

https://www.opentools.studio/
272•bouh•2h ago•72 comments

Organic Maps

https://organicmaps.app/
767•tosh•9h ago•216 comments

Show HN: Homegames. An open-source game platform I've been making for 8 years

https://homegames.io
71•homegamesjoseph•2h ago•25 comments

New AI tutor achieves 0.71-1.30 SD effect size in Dartmouth course [pdf]

https://intextbooks.science.uu.nl/workshop2026/files/itb26_s1s2.pdf
112•jonahbard•5h ago•75 comments

The future of Flipper Zero development

https://blog.flipper.net/future-of-flipper-zero-development/
199•croes•5h ago•67 comments

Mr. Baby Paint and accidentally discovering a new cellular automata

https://tekstien-marginaalien-keskus.aalto.fi/residenssi/heikki/blog/004-december-2/
91•jfil•2d ago•15 comments

Zero-copy in Go: sendfile, splice, and the cost of io.Copy

https://segflow.github.io/post/zero-copy-sendfile-splice/
48•mrngm•3h ago•8 comments

Connections in Math: the two kinds of random

https://stillthinking.net/posts/connections-in-math-two-kinds-of-random/
5•pcael•22m ago•0 comments

Starring the Computer

https://www.starringthecomputer.com/computers.html
148•gitowiec•6h ago•37 comments

It's not about physical vs. digital games, it's about ownership

https://popcar.bearblog.dev/its-about-ownership/
282•popcar2•8h ago•215 comments

Composite Video on the NES: Why's it so wobbly?

https://nicole.express/2026/phase-altering-by-line.html
22•zdw•2h ago•1 comments

Delta flight hit by firework while landing at Midway Airport on Fourth of July

https://www.nbcchicago.com/news/local/delta-flight-hit-by-firework-while-landing-at-midway-airpor...
40•randycupertino•4h ago•17 comments

Dungeon Proof Crawler: learn how to write proofs with RPG

https://dhilst.github.io/algae/game/index.html
24•SchwKatze•2h ago•11 comments

Dependencies should be fetched directly from VCS

https://www.arp242.net/deps-vcs.html
30•mrngm•3h ago•17 comments

Cursed circuits #5: capacitance multiplier

https://lcamtuf.substack.com/p/cursed-circuits-capacitance-multiplier
36•surprisetalk•3h ago•2 comments

Pint in England

https://dispatch-media.com/the-best-pint-in-england/
24•gripfx•2h ago•10 comments

You need a webring

https://shub.club/writings/2026/july/you-need-a-webring/
47•forthwall•5h ago•31 comments

CoCom regulations and GPS receivers for balloons and cubesats

https://space.stackexchange.com/questions/14687/current-situation-with-cocom-regulations-and-gps-...
12•vinnyglennon•2h ago•2 comments

Introduction to Compilers and Language Design (2021)

https://dthain.github.io/books/compiler/
264•AlexeyBrin•11h ago•44 comments

DNSGlobe – Rust TUI to watch DNS propagate around the world

https://github.com/514-labs/dnsglobe
13•Callicles•1h ago•9 comments

Show HN: Osint tool that finds exposed files on domains

https://search.cerast-intelligence.com/
20•PatchRequest•3h ago•6 comments

Completing a computer science degree on coursera

https://notesbylex.com/completing-a-computer-science-degree-on-coursera
72•lexandstuff•2h ago•45 comments

Artificial Adventures

https://www.scattered-thoughts.net/writing/artificial-adventures/
8•jamii•3d ago•0 comments

Had an idea for a Rust editor with simple Vim mode for learning

https://github.com/electronicsleep/rust-vim
8•ElectronicSleep•2h ago•1 comments

Run Windows 2000 on a DEC Alpha with a new es40 fork

https://raymii.org/s/blog/Run_Windows_2000_for_Dec_Alpha_on_a_new_es40_fork.html
98•jandeboevrie•10h ago•53 comments

The great blogging collapse: What happened to 100 successful blogs?

https://danielstanica.com/posts/Great-Blogging-Collapse
152•thm•3d ago•115 comments

We Always Leave Things Unfinished

https://bigreaderbadgrades.substack.com/p/we-always-leave-things-unfinished
36•bryanrasmussen•3d ago•2 comments

Installing A/UX 1.1 like it's the 90s

https://thomasw.dev/post/aux11/
54•zdw•7h ago•17 comments

Johnson Thermoelectric Energy Converter

https://en.wikipedia.org/wiki/Johnson_thermoelectric_energy_converter
11•msk-lywenn•2d ago•0 comments

The full stack of terminals explained

https://ahmadawais.com/the-full-stack-of-terminals-explained-terminal-shell-tty-console-posix-ans...
20•ludicrousdispla•4h ago•4 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.