frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Longtime Mozilla Support Japanese Community Shuts Down over AI Translation Usage

https://support.mozilla.org/en-US/forums/contributors/717446
185•phantomathkg•1h ago•90 comments

Rust's TUI Revolution

https://ratatui.rs/showcase/apps/
53•AbuAssar•1h ago•15 comments

Solarpunk is happening in Africa

https://climatedrift.substack.com/p/why-solarpunk-is-already-happening
624•JoiDegn•8h ago•308 comments

Recursive macros in C, demystified (once the ugly crying stops)

https://h4x0r.org/big-mac-ro-attack/
39•eatonphil•3h ago•24 comments

Dillo, a multi-platform graphical web browser

https://github.com/dillo-browser/dillo
257•nazgulsenpai•9h ago•94 comments

ChatGPT terms disallow its use in providing legal and medical advice to others

https://www.ctvnews.ca/sci-tech/article/openai-updates-policies-so-chatgpt-wont-provide-medical-o...
247•randycupertino•10h ago•234 comments

Firefox profiles: Private, focused spaces for all the ways you browse

https://blog.mozilla.org/en/firefox/profile-management/
161•darkwater•1w ago•75 comments

Why aren't smart people happier?

https://www.theseedsofscience.pub/p/why-arent-smart-people-happier
231•zdw•11h ago•341 comments

New gel restores dental enamel and could revolutionise tooth repair

https://www.nottingham.ac.uk/news/new-gel-restores-dental-enamel-and-could-revolutionise-tooth-re...
384•CGMthrowaway•8h ago•159 comments

The state of SIMD in Rust in 2025

https://shnatsel.medium.com/the-state-of-simd-in-rust-in-2025-32c263e5f53d
170•ashvardanian•9h ago•94 comments

The Basic Laws of Human Stupidity (1987) [pdf]

https://gandalf.fee.urv.cat/professors/AntonioQuesada/Curs1920/Cipolla_laws.pdf
53•bookofjoe•5h ago•23 comments

Ruby and Its Neighbors: Smalltalk

https://noelrappin.com/blog/2025/11/ruby-and-its-neighbors-smalltalk/
178•jrochkind1•13h ago•98 comments

Brain-IT: Image Reconstruction from fMRI via Brain-Interaction Transformer

https://AmitZalcher.github.io/Brain-IT/
8•SerCe•1h ago•0 comments

NY school phone ban has made lunch loud again

https://gothamist.com/news/ny-smartphone-ban-has-made-lunch-loud-again
233•hrldcpr•15h ago•177 comments

Carice TC2 – A non-digital electric car

https://www.caricecars.com/
193•RubenvanE•14h ago•150 comments

The shadows lurking in the equations

https://gods.art/articles/equation_shadows.html
261•calebm•14h ago•82 comments

A Lost IBM PC/at Model? Analyzing a Newfound Old Bios

https://int10h.org/blog/2025/11/lost-ibm-at-model-bios-analysis/
68•TMWNN•7h ago•12 comments

Radiant Computer

https://radiant.computer
183•beardicus•15h ago•133 comments

Vacuum bricked after user blocks data collection – user mods it to run anyway

https://www.tomshardware.com/tech-industry/big-tech/manufacturer-issues-remote-kill-command-to-nu...
195•toomanyrichies•4d ago•61 comments

An eBPF Loophole: Using XDP for Egress Traffic

https://loopholelabs.io/blog/xdp-for-egress-traffic
213•loopholelabs•1d ago•69 comments

I was right about dishwasher pods and now I can prove it [video]

https://www.youtube.com/watch?v=DAX2_mPr9W8
336•hnaccount_rng•1d ago•225 comments

FAA to cut flights by 10% at 40 major airports due to government shutdown

https://www.cnbc.com/2025/11/05/faa-cuts-flight-capacity-shutdown.html
96•mikhael•1h ago•86 comments

Gloomth

https://www.lrb.co.uk/the-paper/v47/n20/jon-day/gloomth
5•prismatic•6d ago•0 comments

Timing Wheels

https://pncnmnp.github.io/blogs/timing-wheels.html
38•pncnmnp•4d ago•1 comments

Absurd Workflows: Durable Execution with Just Postgres

https://lucumr.pocoo.org/2025/11/3/absurd-workflows/
109•ingve•2d ago•22 comments

Show HN: The Legal Embedding Benchmark (MLEB)

https://huggingface.co/blog/isaacus/introducing-mleb
6•ubutler•1w ago•0 comments

I want a good parallel language [video]

https://www.youtube.com/watch?v=0-eViUyPwso
60•raphlinus•1d ago•34 comments

App Store web has exposed all its source code

https://www.reddit.com/r/webdev/comments/1onnzlj/app_store_web_has_exposed_all_its_source_code/
194•redbell•2d ago•59 comments

Unicode Footguns in Python

https://pythonkoans.substack.com/p/koan-15-the-invisible-ink
31•meander_water•1w ago•9 comments

SPy: An interpreter and compiler for a fast statically typed variant of Python

https://antocuni.eu/2025/10/29/inside-spy-part-1-motivations-and-goals/
237•og_kalu•6d ago•110 comments
Open in hackernews

Recursive macros in C, demystified (once the ugly crying stops)

https://h4x0r.org/big-mac-ro-attack/
39•eatonphil•3h ago

Comments

hyperhello•1h ago
Can I use this technique to expand MACRO(a,b,c,…) into something like F(a,b,c…); G(a,b,c…)?
viega•56m ago
That's just:

``` #define MACRO(...) F(__VA_ARGS__); G(__VA_ARGS__) ```

The technique in the article is more often used to type check the individual parameters, or wrap a function call around them individually, etc.

hyperhello•39m ago
Ok. How about into F(a,”a”);F(b,”b”);etc.

The problem being automating enums and their names in one call. Like MACRO(a,b,c) and getting a map from a to “a”.

viega•34m ago
100%, that's definitely easy to do once you understand the technique.
hyperhello•30m ago
Please?
viega•17m ago
I'm on my phone, but if you start with the top 8 lines in the code box under the ascii art, you'll get an implementation of `H4X0R_MAP()`; the bottom two lines are an example, and you can just write yourself a body that produces one term. Only thing you need to know beyond that is the stringify operator.
viega•14m ago
And I should say, if you want to apply the same transformation to arguments twice, but call F() separately from G() per your starting example, you'd just apply your map twice in your top-level macro.
dandersch•1h ago
Related: The Preprocessor Iceberg https://jadlevesque.github.io/PPMP-Iceberg/

There you can find a recursive macro expansion implementation (as a gcc hack) that fits on a slide:

  #2""3
  
  #define PRAGMA(...) _Pragma(#__VA_ARGS__)
  #define REVIVE(m) PRAGMA(push_macro(#m))PRAGMA(pop_macro(#m))
  #define DEC(n,...) (__VA_ARGS__)
  #define FX(f,x) REVIVE(FX) f x
  #define HOW_MANY_ARGS(...) REVIVE(HOW_MANY_ARGS) \
      __VA_OPT__(+1 FX(HOW_MANY_ARGS, DEC(__VA_ARGS__)))
  
  int main () {
      printf("%i", HOW_MANY_ARGS(1,2,3,4,5)); // 5
  }
It sounds like the one in the article works for more compilers, but there doesn't seem to be a copy-pasteable example anywhere to check for myself. Also, the "Our GitHub Org" link on the site just links to github.com.
lifthrasiir•1h ago
Ask and you'll get: https://c.godbolt.org/z/rKsWT5E9T

It seems that MSVC doesn't like those macros, though.

david2ndaccount•33m ago
Works with MSVC if you add /Zc:preprocessor (to get a standard compliant preprocessor instead of the legacy one).
viega•1h ago
Author of the article here.

Absolutely, the code box under the ascii art is a complete implementation, just paste that in a C file, and then use `H4X0R_VA_COUNT(...)`.

Or, you could follow the link the my typed variadic arguments article (from which this post forked off). The repo there is: https://codeberg.org/h4x0r/vargs

viega•1h ago
And yes, GCC extensions are often going to be adopted in clang, but generally not the broader world of C and C++ compilers. Everything in my article conforms to the standard.
fuhsnn•8m ago
I played with a lot of preprocessor implementations and did my own (redesigned chibicc's expansion algorithm), not many of them even have paint-blue behavior exactly right (the standard text is vague, to me it was more "matching GCC's" than "conforming to standard").
viega•2m ago
That's interesting. I agree with you that the standards text is pretty vague. I think that's why other attempts to show how to do this kind of thing don't get deep enough on the semantics, and why I adopted a "try it and see" strategy.

I do try to avoid this kind of thing unless necessary, so I don't have experience as to where the different compilers will fall down on different corner cases. I'd find it very interesting though, so please do share if you kept any record or have any memory!

stevefan1999•1h ago
I used to write a preprocessor until I noticed those kind of thing...I stopped writing it after that
russfink•47m ago
Is this a DoS risk - code that sends your build chain into an infinite loop?
viega•41m ago
No. Other modern languages have strong compile-time execution capabilities, including Zig, Rust and C++. And my understanding is that C is looking to move in that direction, though as with C++, macros will not go away.
saghm•33m ago
Without any specific implementation of a constraint it certainly can happen, although I'm not totally sure that it's something to be concerned about in terms of a DOS as much as a nuisance when writing code with a bug in it; if you're including malicious code, there's probably much worse things it could do if it actually builds properly instead of just spinning indefinitely.

Rust's macros are recursive intentionally, and the compiler implements a recursion limit that IIRC defaults to 64, at which point it will error out and mention that you need to increase it with an attribute in the code if you need it to be higher. This isn't just for macros though, as I've seen it get triggered before with the compiler attempting to resolve deeply nested generics, so it seems plausible to me that C compilers might already have some sort of internal check for this. At the very least, C++ templates certainly can get pretty deeply nested, and given that the major C compilers are pretty closely related to their C++ counterparts, maybe this is something that exists in the shared part of the compiler logic.

viega•6m ago
C++ also has constexpr functions, which can be recursive.

All code can have bugs, error out and die.

There are lots of good reasons to run code at compile time, most commonly to generate code, especially tedious and error-prone code. If the language doesn't have good built-in facilities to do that, then people will write separate programs as part of the build, which adds system complexity, which is, in my experience, worse for C than for most other languages.

If a language can remove that build complexity, and the semantics are clear enough to the average programmer (For example, Nim's macro system which originally were highly appealing (and easy) to me as a compiler guy, until I saw how other people find even simple examples completely opaque-- worse than C macros.

pjsg•43m ago
I wept when the author mentioned implementing SHA256 in macros.
viega•35m ago
LOL, I suffered so you didn't have to.
fuhsnn•27m ago
I wonder if the author is aware of the __VA_TAIL__ proposal[1], it covered similar grounds and IMO very well thought out, but unfortunately not accepted into C2Y (judging from committee meeting minutes).

[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3307.htm

viega•20m ago
Yes, I know that it was not accepted, but do not have any color on why not. It's well thought out; but I do not think the semantics are self-evident to the average C programmer who already finds the preprocessor inscrutable.