0

If I need to reference the size of two 4x4 float matrices, which is 128, across multiple functions and stuff, what is the best way to do it that doesn't use macros. I know that for something trivial like this it doesn't really matter, but its just for getting a better understanding of all of the stuff C++ has (const, constexpr, consteval, constinit, static, etc). And since that variable is only going to be reference inside one file, it should be static, but I heard somewhere that constexpr or const global variables are automatically static or something like that (I could be completely wrong so correct me if so).

With all that said, what are the difference between and which is the best for just keeping a number under a name across functions inside only one file? (again, with no macros):

const size = 128;
constexpr size = 128;
constinit size = 128;
static const size = 128;
static constexpr size = 128;
static constinit size = 128;
Karlos
  • 197
  • 7
  • 3
    [constexpr vs const](https://stackoverflow.com/questions/57845131/what-is-constinit-in-c20) and [constinit](https://stackoverflow.com/questions/57845131/what-is-constinit-in-c20) – TruthSeeker Apr 28 '22 at 12:52
  • 1
    *"what are the difference between"*. The question seems too broad to be covered in one SO post IMO. Instead refer to a [good C++ book](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – Jason Apr 28 '22 at 12:55

0 Answers0