frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Soft launch of open-source code platform for government

https://www.nldigitalgovernment.nl/news/soft-launch-for-government-open-source-code-platform/
287•e12e•4h ago•91 comments

Ghostty is leaving GitHub

https://mitchellh.com/writing/ghostty-leaving-github
2898•WadeGrimridge•17h ago•871 comments

HashiCorp co-founder says GitHub 'no longer a place for serious work'

https://www.theregister.com/2026/04/29/mitchell_hashimoto_ghostty_quitting_github/
201•terminalbraid•1h ago•105 comments

Letting AI play my game – building an agentic test harness to help play-testing

https://blog.jeffschomay.com/letting-ai-play-my-game
8•jschomay•57m ago•0 comments

Bugs Rust won't catch

https://corrode.dev/blog/bugs-rust-wont-catch/
414•lwhsiao•11h ago•215 comments

He asked AI to count carbs 27000 times. It couldn't give the same answer twice

https://www.diabettech.com/i-asked-ai-to-count-my-carbs-27000-times-it-couldnt-give-me-the-same-a...
122•sarusso•1h ago•145 comments

Before GitHub

https://lucumr.pocoo.org/2026/4/28/before-github/
543•mlex•16h ago•174 comments

How ChatGPT serves ads

https://www.buchodi.com/how-chatgpt-serves-ads-heres-the-full-attribution-loop/
400•lmbbuchodi•13h ago•271 comments

Stardex Is Hiring a Founding Customer Success Lead

https://www.ycombinator.com/companies/stardex/jobs/6GCK1HC-founding-customer-success-lead
1•sanketc•1h ago

Show HN: Rip.so – a graveyard for dead internet things

https://rip.so
112•bozdemir•4h ago•83 comments

Show HN: Adblock-rust Manager – Firefox extension to enable the Brave ad blocker

https://github.com/electricant/adblock-rust-manager
7•electricant•1h ago•4 comments

Show HN: Rocky – Rust SQL engine with branches, replay, column lineage

https://github.com/rocky-data/rocky
84•hugocorreia90•23h ago•23 comments

HardenedBSD Is Now Officially on Radicle

https://hardenedbsd.org/article/shawn-webb/2026-04-26/hardenedbsd-officially-radicle
104•lftherios•7h ago•24 comments

Show HN: Auto-Architecture: Karpathy's Loop, pointed at a CPU

https://github.com/FeSens/auto-arch-tournament/blob/main/docs/auto-arch-tournament-blog-post.md
191•fesens•20h ago•51 comments

Coffee with a splash of physics: how to make the most out of your brew

https://physicsworld.com/a/coffee-with-a-splash-of-physics-how-to-make-the-most-out-of-your-brew/
21•sohkamyung•1h ago•4 comments

Withnail's Coat and I

https://ontherow.substack.com/p/withnails-coat-and-i
107•apollinaire•1d ago•14 comments

Low-Compilation-Cost Register Allocation in LLVM-Based Binary Translation

https://dl.acm.org/doi/abs/10.1145/3767295.3803591
42•matt_d•6h ago•1 comments

OpenAI models coming to Amazon Bedrock: Interview with OpenAI and AWS CEOs

https://stratechery.com/2026/an-interview-with-openai-ceo-sam-altman-and-aws-ceo-matt-garman-abou...
291•translocator•18h ago•97 comments

GitHub – DOS 1.0: Transcription of Tim Paterson's DOS Printouts

https://github.com/DOS-History/Paterson-Listings
6•s2l•2h ago•0 comments

Notepad++ Code Editor Comes to Mac After 20-Year Wait

https://www.macrumors.com/2026/04/29/notepad-plus-plus-editor-comes-to-mac/
12•Brajeshwar•40m ago•3 comments

I won a championship that doesn't exist

https://ron.stoner.com/How_I_Won_a_Championship_That_Doesnt_Exist/
198•SEJeff•17h ago•108 comments

GitHub RCE Vulnerability: CVE-2026-3854 Breakdown

https://www.wiz.io/blog/github-rce-vulnerability-cve-2026-3854
397•bo0tzz•21h ago•85 comments

Who owns the code Claude Code wrote?

https://legallayer.substack.com/p/who-owns-the-claude-code-wrote
455•senaevren•1d ago•424 comments

Talkie: a 13B vintage language model from 1930

https://talkie-lm.com/introducing-talkie
719•jekude•1d ago•302 comments

Gallium oxide electronics withstand extreme cold

https://discovery.kaust.edu.sa/en/article/26858/gallium-oxide-electronics-withstand-extreme-cold/
60•giuliomagnifico•2d ago•5 comments

Warp is now open-source

https://www.warp.dev/blog/warp-is-now-open-source
312•meetpateltech•21h ago•92 comments

Your phone is about to stop being yours

https://keepandroidopen.org/en/
1496•doener•22h ago•718 comments

Behavioral timescale synaptic plasticity rewires the brain after an experience

https://www.quantamagazine.org/a-new-type-of-neuroplasticity-rewires-the-brain-after-a-single-exp...
135•ibobev•1d ago•7 comments

Intel Arc Pro B70 Review

https://www.pugetsystems.com/labs/articles/intel-arc-pro-b70-review/
182•zdw•5d ago•111 comments

Show HN: Drive any macOS app in the background without stealing the cursor

https://github.com/trycua/cua
156•frabonacci•21h ago•35 comments
Open in hackernews

Detecting if an expression is constant in C

https://nrk.neocities.org/articles/c-constexpr-macro
62•ingve•1y ago

Comments

Y_Y•1y ago
If C23 is why not use constexpr?

https://en.cppreference.com/w/c/language/constexpr

lpribis•1y ago
This is not for declaring constexpr variables, it is about how to implement a checker function that verifies an inline expression is constant. Plus some of the examples work back to C99 instead of C23, which I would wager close to zero people are using in real-world code bases.
cmptrnerd6•1y ago
You'd probably still win the wager but I do want to say there are some of us using C23. We even use it in our embedded systems running on arm based microcontrollers. Though we still do maintain some C89 code :(
pantalaimon•1y ago
C23 on embedded ARM is entirely painless as it’s all upstream GCC these days anyway.

The problem is if you want to also still support esp8266 which is forever stuck at GCC 8.4

Y_Y•1y ago

  #define C(x) ((constexpr typeof(x)){ (x) })
Aardwolf•1y ago
The article mentions C23, but what they're trying to do is detect if something (possibly declared by someone else?) is a compile time constant, not to declare it as such
re•1y ago
Is there a use case for such a macro, or is it just a puzzle for its own sake?
uecker•1y ago
Probably not. The Linux kernel has one.
apple1417•1y ago
I've seen something related, which returned a bool instead of failing compilation, be used to switch between a path the optimiser could inline and some assembly. You could probably use this to make sure it was always inlined.
kevingadd•1y ago
If you're writing code that needs to behave deterministically and not have side effects, you could use this to make violations of determinism/side-effect-freeness fail fast, I guess?
variadix•1y ago
The use case that comes to mind is doing manual compile time optimization based on macro arguments. E.g. you have some assembly block that is fast but requires some immediate arguments, and you have a fallback path for the dynamic case, and you want to determine which one to call at compile time based on whether the arguments are constants or not.
JacksonAllan•1y ago
I use something similar in a container library to warn the user if he or she supplies an argument with potential side effects to a macro that evaluates it multiple times:

https://github.com/JacksonAllan/CC/blob/42a7d810274a698dff87...

Specifically, if (arg)==(arg) is not a constant expression, then it could have side effects.

However, this mechanism does generate some annoying false positives, as shown below:

  // Create a map with int keys and values that are vectors of floats:
  map( int, vec( float ) ) our_map;
  init( &our_map );
  
  // Create a vector of floats:
  vec( float ) our_vec;
  init( &our_vec );
  push( &our_vec, 1.23f );
  
  // Insert the vector into the map.
  insert( &our_map, 456, our_vec );
  
  // Generates a warning because get checks its first argument for side
  // effects and the compiler can't tell that the first argument of the
  // outermost get has none:
  printf( "%f", *get( get( &our_map, 456 ), 0 ) );
  
  // The "proper", albeit cumbersome, way to achieve the same thing without a
  // warning:
  vec( float ) *itr = get( &our_map, 456 );
  printf( "%f", *get( itr, 0 ) );
rurban•1y ago
The macro should be called IS_CONST(), not C()
immibis•1y ago
To determine if an expression is constant in C, one must determine if an expression in C is constant.
atiedebee•1y ago
I agree, but for a blog post it is more concise (IS_CONST or anything that is long would take up a lot more screen real estate on my phone).
mrgriffin•1y ago
Would you expect IS_CONST to evaluate to the constant? With a name like that I would expect it to evaluate to true/false.

C here is asserting that the value inside is a constant and then evaluating to that constant.

rurban•1y ago
Uh, you are right. C is the right name. It throws.

I mixed it up with a similar compile-time constness check in some of my libraries, where I decided if const of not. gcc throws, only clang could give me a proper answer.

uecker•1y ago
One can use _Pragma inside macros
listeria•1y ago
Apparently the static_assert trick doesn't work with GCC, it just compiles it with a warning if it's not a constant expression:

  warning: expression in static assertion is not an integer constant expression [-Wpedantic]
Instead you can use the sizeof + compound literal with array type, use the comma operator to preserve the type of the expression and cast the result of sizeof to void to suppress the warning:

  #define C(x) ( (void)sizeof( (char [(int)(x) || 1]){0} ), (x) )
The only problem is that it doesn't support floating point expressions
hermitdev•1y ago
> And I'd rather keep the library warning free instead of telling the users to switch warnings off.

Thank you! Separately, but related: fuck you, Google! (every time I have to deal with protobuf in C++, I curse Google and their "we don't give a shit about signed vs unsigned comparisons").

fluoridation•1y ago
I just turn warnings off for protobuf stuff. In general I do that for any code I don't own but have to compile.
anyfoo•1y ago
And I don't think there's an excuse not to. I work on giant projects with tons of people, that still manage to use -Werror.

Yeah, some warnings are turned off, but not as many as you'd think, and usually for good reasons, which also includes deliberate design decisions. For example, we don't care about pre-C11 compatibility (because we won't build for pre-C11), so that warning is off. We also like 0-sized arrays, so that warning is off as well.

It's a moving target, because compiler engineers add new warnings over time. Adapting the new compiler means taking care of the new warnings. There's almost always a way to do so instead of turning a new warning off.

immibis•1y ago
The person who writes the library isn't using the same compiler as you.
anyfoo•1y ago
True, so?
pabs3•1y ago
So turn on -Werror in your CI builds, but don't turn it on for all builds.
anyfoo•1y ago
I mean, yeah, obviously that a)only works when we build our projects ourselves, and b) for external libraries you have less control over that.
immibis•1y ago
Fuck projects that ship conpile scripts with -Werror.
anyfoo•1y ago
I don't understand this discussion. What I said was that for our big projects internally, we keep them warning-free, and -Werror obviously helps tremendously with that. Nobody said you need to ship externally with -Werror, or anything about external libraries the project may be using.

By keeping your own project warning-free in your environment, you are doing a service to everyone.

pabs3•1y ago
Sounds like you are doing the right thing (-Werror internally, not externally). So this discussion is probably just based on a miscommunication. Happens pretty often on HN unfortunately.
jcelerier•1y ago
3rdparty libs should be treated as -isystem. Otherwise you're just needlessly paying for other's mistakes.
hermitdev•1y ago
The problem is: it's infectious into the generated code, as well. Is that 3rd party or not? Yes, it was generated by a 3rd party tool, but from, ostensibly, _your_ protobuf file.

edit to add: and yes `-isystem` is absolutely a useful tool. If memory serves, though, it doesn't protect from macro or template expansions, though.

variadix•1y ago
__builtin_choose_expr can be used instead of a ternary to avoid the type conversion rules that require the typeof cast
fuhsnn•1y ago
It's great of programmers to aim for portability, but frankly it's kind of a stretch that an arbitrary C compiler that is limited in standard support would the same time be sophisticated enough to process these tricks as intended.

In my fork of chibicc (a small C11 compiler) there are plenty of additional logic that were implemented solely to play nice with C tricks from real world projects that could have been easier if they target later standards. The most recent being how curl's build script determines the size of primitive types: they use (sizeof(T) == N) as a case index and expect the compiler to error on case-duplication[1], I had to add a backtracking loop to check exactly that[2]. I'm not complaining as more error checks isn't a bad thing, however, I'll advise programmers willing to invest in obscure tricks to actually test them on obscure compilers (instead of just flipping -std).

[1]: https://github.com/curl/curl/blob/339464432555b9bd71a5e4a4c4...

[2]: https://github.com/fuhsnn/slimcc/blob/54563ecae8480f836a0bb2...

listeria•1y ago
If the goal of testing on obscure compilers is to enhance such compilers then I'm all for it. But I don't see much value in having to dance around implementation details to support a compiler which isn't standards compliant. Ideally standards conforming code should just work, that's the point of conforming to a standard.
immibis•1y ago
Depends if you want people to be able to use your library with those compilers or not. If it's free software, fine. Don't fire well-paying customers though.
anyfoo•1y ago
curl is one of those projects that's probably meant to be ultra-portable, though, working across an incredibly wide range of platforms, some probably with comparably ancient compilers.

I don't actually know any details so I don't want to presume, but it wouldn't surprise me at all if targeting later standards simply isn't an option for the curl project due to portability. It may be that the (sizeof(t) == n) trick may just be what consistently works across all targets. (Until yours came along.)

I do remember when configure etc. still had to check whether ANSI prototypes (as opposed to the original K&R style declarations) were supported... I hope that check isn't much of a thing anymore.

dandersch•1y ago
>And I'd rather keep the library warning free instead of telling the users to switch warnings off.

Why not push/pop warnings to ignore in the library?

  _Pragma("GCC diagnostic push")
  _Pragma("GCC diagnostic ignored \"-Wshadow\"")
  int a = 1;
  {
      int a = 2;
  }
  _Pragma("GCC diagnostic pop")
kevin_thibedeau•1y ago
This sort of thing is better set in CMake or equivalent with file specific flags to disable diagnostics. Then you don't have non-portable cruft littering the code, you don't have to touch third party code, and there is a more centralized accounting of what marginal code you're hacking around. The loss of specificity is rarely going to be a problem.
cperciva•1y ago
If you disable warnings in your makefile, you'll lose them for the entire C file. Pragma warnings as above allow them to be disabled for just the problematic code in question.
einpoklum•1y ago
> with file specific flags

But you don't want to disable warnings throughout the file, just locally.

> Then you don't have non-portable cruft littering the code,

You can make it perfectly portable, with a little macro work. See, ,for example:

https://github.com/eyalroz/printf/blob/013db1e345cbb166a7eb7...

(this is from the standalone-no-libc-printf-family-implementation I maintain; the library is C, the test suite is C++ but it doesn't matter for the purposes of my point here.)

and that you only need to do once in your project (you can make it your own header). Even when it comes to use - you can place your warning-disabling within another macro, so that you end up only using a simple single macro for your actual code.

o11c•1y ago
This probably isn't relevant anymore, but for now-old (4.x I think) versions of GCC, there are a couple of caveats:

* Some versions can only change compiler options at top level, not within a function.

* I had problems with trying to push/ignore/pop a warning around an expression in a macro, since the entire thing expands at a single location.

gitroom•1y ago
This takes me back - all those compiler hacks just to keep stuff portable kinda drive me nuts tbh. I love seeing people push for warning-free code, though.
jesse__•1y ago
> And this cannot be silenced with #pragma since it's a macro, so the warning occurs at the location where the macro is invoked.

I seem to remember there's actually a solution for this .. at least on clang and I think MSVC .. you can programmatically turn warnings on/on with the _Pragma() macro. I don't remember exactly what you put in it, but it's designed specifically for this kind of macro nonsense

_sbrk•1y ago
gcc will not let you actually define a negatively-sized array. Check it with some simple code -- I did. Even with -Wall -Wextra -O1 -std=c11 -Wpedantic, if I actually try to create foo[-1], on the stack or in BSS, I get the proper error: error: size of array 'foo' is negative
o11c•1y ago
Semi-related: given an expression which is an integer constant, convert it to a statically-allocated char array. With appropriate sigils this can be extracted via `strings(1)`, even when cross-compiling.

If you don't know what type of integer your preprocessor is using for arithmetic, you can still do right-shifts by up to 14 at a time, since `int` must be at least 16 bits and you can't use the sign bit.

pjmlp•1y ago
Meanwhile in C++ land, use if consteval, unless not able to use recent standards.