Solved

What is the array size?

Posted on 2013-06-24
1
271 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

705 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