News for hackers. Stuff that matters.
Re:Trying out C++20's modules with Clang and Make by mgaunard on Sunday October 15, 2023 @01:01PM (#37891416)
The semantics are literally "it's the same as copy-pasting it where it's used". It doesn't get simpler than this.

There are much more things going on in the module system that you'd have to know about if you care about what's actually going on.

Re:Trying out C++20's modules with Clang and Make by dagmx on Sunday October 15, 2023 @01:10PM (#37891502)
The module system doesn’t have side effects on inclusion, whereas headers do.

So again, maybe if you have a smaller, cleaner or dependency free codebase, then it’s not an issue.

But in any codebase of major scale or legacy, headers can introduce several issues that aren’t possible with the module interface.

Re:Trying out C++20's modules with Clang and Make by mgaunard on Sunday October 15, 2023 @01:42PM (#37891743)
The side-effects are merely the rules of C++, that you already know by virtue of writing C++.
Re:Trying out C++20's modules with Clang and Make by dagmx on Sunday October 15, 2023 @01:50PM (#37891802)
I feel like you’re talking past any of the caveats I’ve mentioned twice. I have no interest in belabouring the point with someone who’s clearly ignoring what’s being written. Have a good day.
Re:Trying out C++20's modules with Clang and Make by maccard on Sunday October 15, 2023 @03:33PM (#37892682)
You're really burying the lede here.

Headers are literal copy paste, and are entirely different. Anyone who has ever had to define WIN32_LEAN_AND_MEAN knows that there's _way_ more going on here.

Re:Trying out C++20's modules with Clang and Make by dagmx on Sunday October 15, 2023 @05:00PM (#37893334)
This exactly, thank you. Sometimes you can’t untangle the defines in another header and they infect your own.

Modules are a nice barrier to guard against side effects.

Re:Trying out C++20's modules with Clang and Make by mathstuf on Sunday October 15, 2023 @05:32PM (#37893573)
Yes, the number of times I've had a `LoadLibrary` function name conflict with `windows.h`'s `A`/`W` suffix-switching or had to deal with X11's `#define Status int` "typedef" mucking with completely unrelated code is…sad.
Re:Trying out C++20's modules with Clang and Make by mgaunard on Monday October 16, 2023 @03:52AM (#37896894)
Just don't include those in headers.
Re:Trying out C++20's modules with Clang and Make by maccard on Monday October 16, 2023 @04:46AM (#37897197)
That's not possible. Windows.h is a requirement for anyone working on Windows. Various standard library implementations make use of macros to implement debug-only assertions, or bounds checks in containers.
Re:Trying out C++20's modules with Clang and Make by mgaunard on Monday October 16, 2023 @05:49AM (#37897595)
Don't include it in headers = only include it in a .cpp file.
Re:Trying out C++20's modules with Clang and Make by mathstuf on Monday October 16, 2023 @08:42AM (#37899047)
Because `void*` to pass `HANDLE` around is better how? Maybe if you're able to hermetically seal off platform-specific bits, but usually you'll have two parts that want to talk about Windows API types across their call boundaries…
Re:Trying out C++20's modules with Clang and Make by mgaunard on Monday October 16, 2023 @04:51PM (#37906432)
It's called encapsulation.
Re:Trying out C++20's modules with Clang and Make by mathstuf on Tuesday October 17, 2023 @09:10AM (#37914410)
Sure, but I also prefer talking directly about what you're talking about though. If you have some Windows implementations that need to talk to each other, I'd rather they use HANDLE and HMODULE than "void* winkwinknudgenudge" style things. Hopefully users don't need to include these headers directly (but sometimes they do), but it's still something you need to consider in the APIs and such because while the header might say LoadLibrary, the caller is going to need to include windows.h and deal with the #define anyways.
Re:Trying out C++20's modules with Clang and Make by mgaunard on Tuesday October 17, 2023 @03:16PM (#37920183)
any interaction with the win32 api should be hidden within your library.

Surely you want your code to be portable to begin with?

Re:Trying out C++20's modules with Clang and Make by mathstuf on Tuesday October 17, 2023 @08:11PM (#37923298)
It can be portable and still want to expose native information. SDL2 is probably something we can all agree is portable, but this still exists: https://wiki.libsdl.org/SDL2/SDL_SysWMmsg