Quantum Leaps - 2025-03-27

Here is an interesting question: How do you declare, but NOT define, a variable in file scope?

AFIK, there is no way to do this in C or C++. Consequently, what is QM to do when you ask it to do just that?

The only workaround for this that I see at this moment is NOT to do this to QM. If you have a file-scope variable, put it into the file directly (as static Foo attr;):

file my_file.cpp:

$declare ${my_package} // 'attr' NOT present in my_package

static Foo attr;       // 'Foo' type could be declared in my_package

$define ${my_package}  // could be using 'attr'

--MMS

 

Last edit: Quantum Leaps 2025-04-14