The beauty and simplicity of the good old C-style void* in C++

Programmers are fighting over an old trick, and the comments got spicy fast

TLDR: The article argues that an old, simple way of passing raw data is still the cleanest choice in C++. Commenters pushed back hard, saying newer options may look fussier but better prevent mistakes and make the programmer’s intent clearer — turning a tiny coding choice into a big philosophy fight.

A seemingly tiny coding question — how to pass a chunk of data into a function — turned into a full-on old school vs modern safety showdown. The article basically says: keep it simple, use the classic C-style void* pointer plus a size number, and stop making code look like a paperwork explosion. The author argues that newer options make a straightforward task feel noisier and uglier, especially when all you want is “here’s some memory, do the thing.”

But the real fireworks were in the comments, where readers were absolutely not ready to let that slide. One camp came in swinging with the classic internet rebuttal: simple is nice, but not if it makes mistakes easier and more dangerous. One commenter practically translated the debate into plain English: using the old approach can turn a small slip-up into total chaos, while newer tools better signal what the code is meant to do. Another reader was even harsher, basically saying: if you’re passing a custom data structure around as just raw bytes, maybe you’ve already made a bad design choice.

Still, not everyone was buying the “modern everything” pitch. Some commenters admitted they hate template-heavy code too, but said newer tools win because they keep the data pointer and its size together — fewer chances for human error, fewer mystery bugs. The funniest vibe in the thread? People weren’t just debating code; they were debating taste. One side yelled “readability,” the other yelled “reliability,” and the community turned a tiny programming detail into a drama about whether developers are making code elegant or just dressing it in extra accessories.

Key Points

  • The article presents `const void*` plus a size in bytes as a simple way to define a C++ function that accepts a generic memory block.
  • A `const uint8_t*` parameter requires an explicit cast when passing the address of a custom structure, whereas `const void*` accepts it directly.
  • The article evaluates `std::span`-based signatures, including templated forms, and describes them as more complex for this use case.
  • Examples in the article include functions that hash data, such as with SHA-256, or write binary data to disk.
  • The article suggests SAL annotations like `_In_reads_bytes_(numBytes)` to preserve a `void*` interface while providing additional information to analysis tools.

Hottest takes

"some people never had taste for good reliable code" — gignico
"You would create another function that actually works based off that structure" — voidUpdate
"the pointer and the length are joined together" — themafia
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.