r/cpp • • Jun 18 '26

GCC 17 Lands Initial Infrastructure For C++29

https://www.phoronix.com/news/GCC-17-std-CPP29-Experimental
130 Upvotes

38 comments sorted by

View all comments

Show parent comment

3

u/pjmlp Jun 18 '26

Static libraries definitely work with modules in VC++ with MSBuild, and import std, unless you mean something else.

https://github.com/pjmlp/RaytracingWeekend-CPP/tree/main/OneWeekend/RaytracingLib

8

u/not_a_novel_account cmake dev Jun 18 '26 edited Jun 18 '26

You're doing an import std in the main project, so std.obj is being provided there.

The problem is when you try to use a static library which wants import std in a project which does not itself do import std. CMake does not bundle std.obj into the archive, unless someone else provides it the link fails.

It's entirely possible VS is bundling std.obj and this "just works" for them even when consumed by projects which don't do import std themselves, like a plain C project. That's certainly a solution. I need to boot up a Windows box and check at some point.

3

u/pjmlp Jun 19 '26

I am on Windows and can have a look later today, with VC++ / MS Build though.

2

u/mapronV Jun 19 '26

Can you please share a result? I interested in result of this conversation!

2

u/pjmlp Jun 19 '26 edited Jun 19 '26

It is on github already, https://github.com/pjmlp/staticlib-modules

There are two approaches there, as described on the readme.

EDIT: as per chat conversation, it may be that the way VC++ manages it, even with a .obj and .ifc referenced via the linker (not MSBuild project reference), is actually an ODR reference due to how std.obj ends up on the final binary.

Note, not a linker expert.