Re: Static constant class members

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Vova,

>This construction works fine in gcc 3.3 ...

A "static int const" is a special exemption.

A pointer (even a static const one) is not exempted.

>This is true, but actual value of the constant wouldn't be available in files which includes "TxtVideo.h", so compiler wouldn't insert it as immediate operand, instead it will insert memory reference. Am I wrong ?

You are correct. If you really want it to be an immediate operand in C++, do this:

class TxtVideo
{
public:
static unsigned int* const getVBase() { return (unsigned int* const)0x0C00B8000L; }
...


That will be inserted as an inline function (since it's body is defined in the class), and the inline will optimize down to an immediate.

HTH,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux