Am Dienstag, dem 04.07.2023 um 16:46 +0200 schrieb Rafał Pietrak:... > > > > I think a C++ class (or rather, class template) with inline functions is > > the way to go here. gcc's optimiser will give good code, and the C++ > > class will let you get nice syntax to hide the messy details. > > OK. Thenx for the advice, but going into c++ is a major thing for me and > (at least for the time being) I'll stay with ordinary "big" pointers in > plain C instead.
Depending on what you are doing, "nice syntax" may not be worth dealing with C++ issues. But this depends a lot on circumstances. If the spaces saving are really valuable, I would personally just wrap accesses with a macro. > > There is no good way to do this in C. Named address spaces would be a > > possibility, but require quite a bit of effort and change to the > > compiler to implement, and they don't give you anything that you would > > not get from a C++ class. > > Yes. named address spaces would be great. And for code, too. > While certainly some work, implementation effort for new kinds of named address spaces does not seem to be terrible at first glance: https://gcc.gnu.org/onlinedocs/gccint/target-macros/adding-support-for-named-address-spaces.html > Martin