This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: error: array subscript is not an integer


Hi Manal,

> I usually use typedef to create my type of a standard type. How can I
> use it to create bigger types than the standard?

You need to create a struct.  Here's a short example:

struct MyBigIndex
{
    int lsw;
    int msw;
};

Then you would need to do all the needed math operators on the MyBigIndex
yourself.

That's how the BigNum facility works (except BigNum is stretchy, and the
above example only has two words worth).

> how do I check the maximum allowed in the machine I am using?

~size_t(0) is the theoretical maximum allowed in the machine you are using,
in bytes.

If your data type is a double (64-bit floating point), the maximum size of
your hyper-cube that could be (theoretically) supported in memory is:

size_t maxCube = ~size_t(0) / sizeof(double);

That's before taking into account other things that use memory, such as the
program and the OS.

If your platform is 64-bit, you may still be constrained by what is actually
supported by the hardware.  I wouldn't be surprised if your 64-bit platform
can only address 36-bit, or 40-bit or 44-bit of (real+virtual) memory.

If you need more memory than that, you may need to use an alternative
strategy to represent your hyper-cube, such as a file representation and
what's in memory is a working cache of part of the hyper-cube that exists in
the file.  Or a sparse hyper-cube, perhaps.

HTH,
--Eljay


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]