0

I'm migrating a Petzold-style windows application to C++20 modules. My goal is to learn about the advantages and limits of modules.

After I have overcome several hurdles, one of the last problems left is the Windows resource file. The usual way to define resource identifiers is #define statements in a header file, which is #include'd in both the resource file and the C++ source files.

In the new world of C++ modules, I don't want neither #define nor #include.

Complete renunciation of Windows resources is probably possible, but does not really inspire me.

Is there any reasonable alternative?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • There's only so much C the [resource compiler](https://learn.microsoft.com/en-us/windows/win32/menurc/resource-compiler) understands. If you wish to share symbolic constants between your C++ code and resource scripts, then C preprocessor macros it is. – IInspectable Sep 08 '22 at 14:50
  • @IInspectable: Yes, this is what it looks like at the moment. A better solution would require a new resource compiler. I doubt that Microsoft is still willing to invest anything in this area. Presumably with .NET there are better ways to manage resources. Maybe I'm a bit exotic with my concern to combine a more than 30-year-old technology (winapi) with the latest features of C++. – Peter Kraus Sep 08 '22 at 15:36
  • Well, "new" C++ is still ancient technology, especially when it comes to the build model. If you want a more seamless experience here, Rust's macro system has no problem parsing .rc scripts. Alternatively, make sure the Carbon Language team [learns about your use case](https://github.com/carbon-language/carbon-lang/issues) so that it can be evaluated for future inclusion. – IInspectable Sep 08 '22 at 16:14
  • Imagine a car-crazy man who desperately wants to install a modern Porsche 7-speed dual-clutch transmission in a Shelby Cobra 1967. He has a problem with the connection between the crankshaft and the transmission shaft and asks for help in a forum. Answer: Buy a Tesla. – Peter Kraus Sep 08 '22 at 16:38
  • Stack Overflow is neither a forum, nor is that the answer you got. The comment you actually got: "This is why you cannot connect the crankshift and transmission. You won't be driving your car using this engine. In case you're interested, here are engines that are compatible with the car." – IInspectable Sep 08 '22 at 17:01
  • You're absolutely right. I wanted to be ironic, but as a beginner and non-native speaker, it's hard to strike the appropriate tone. Thanks for the information and nothing for bad. – Peter Kraus Sep 08 '22 at 21:36

0 Answers0