Solved

What is the array size?

Posted on 2013-06-24
1
272 Views
Last Modified: 2013-06-24
/// Maps out the port registers.
    struct PortReg
    {
      volatile uint32  *Set;
      volatile uint32  *Clear;
      volatile uint32  *State;
      volatile uint32  *Mask;
      volatile uint32  *Dir;
      volatile uint32  *FunctionLower;
      volatile uint32  *FunctionUpper;
      volatile uint32  *ModeLower;
      volatile uint32  *ModeUpper;
      volatile uint32  *OutputReg;
    };

    static const PortReg PortRegList[];

Is this allowed?  Aren't we required to specify the array size?
0
Comment
Question by:naseeam
1 Comment
 
LVL 86

Accepted Solution

by:
jkr earned 400 total points
ID: 39273192
Usually, that isn't allowed - the error is 'unkown size'. If you need something like that and be on the "legal" side, make that a

PortReg* PortRegList;

Open in new window


and fill it dynamically after using 'new' for allocation when you know the size. If your compiler allows that, it might have a special extension for that (e.g. gcc allows a non-const value for array sizes, which is also not conformant)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now