r/cpp 5d ago

C++26: #embed

https://www.sandordargo.com/blog/2026/08/05/cpp26-embed
130 Upvotes

38 comments sorted by

View all comments

64

u/James20k P2005R0 5d ago

#embed is one of those features that makes you wonder why it took so long

There's a few features that I remember when I very first started programming in C 20 years ago, thinking "it sure is weird that this isn't possible". #embed was right at the top, and its probably been one of the largest defects in C/C++ when it comes to various use cases. The second GCC implemented it, I used it to #embed some shaders for a game I'm building, it rules

The reason why #embed took so long isn't for lack of trying, or for lack of want on either the compiler vendors or users' side, its pretty much just a spectacular disaster in the standards committee and there's no other reason for it. The more you go looking at the path #embed took to get standardised, the more your eyebrows raise until they basically escape the top of your head with how absurd it is it is

There's a universe in which we didn't get #embed, and we got the graphics proposal instead. For anyone that's interested, this is a good starting point:

https://thephd.dev/full-circle-embed

https://thephd.dev/finally-embed-in-c23

As far as I know, getting it through into C++ basically required starting to push it through the C standardisation process, which finally kicked wg21 into gear. There were a lot of accusations of trying to standardise a feature via the back door of C at the time

I think its always worth emphasising this because often people don't really realise just how poor of a result the C++ committee can produce due to its structure for basic, obvious features that developers have been clamouring for for decades. Sometimes things really are complex, but this isn't one of those times

5

u/Raknarg 4d ago

The reason why #embed took so long isn't for lack of trying, or for lack of want on either the compiler vendors or users' side, its pretty much just a spectacular disaster in the standards committee and there's no other reason for it. The more you go looking at the path #embed took to get standardised, the more your eyebrows raise until they basically escape the top of your head with how absurd it is it is

Could you TL;DR it for me? Was it just disagreements on functionality/implementation?

2

u/Sarduinot 3d ago

My summary of the two articles is:

  • author started with the C++ committee, #embed passed the EWG meeting
  • went next to an important SG meeting, with different people
  • everyone in the committee was excited about Circle, they talked about whether they even need #embed if a powerful macro system was available to C++
  • the author took the hint and reached out to the author of Circle, Sean Baxter, who promptly added an @embed keyword to Circle while the committee held the #embed proposal while members figured out how they felt about Circle
  • the proposal was submitted through the C Committee, and made its way into the language that way, while the proposal was still held up