Solved

What is the array size?

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

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…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

786 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