Solved

What is the array size?

Posted on 2013-06-24
1
286 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

756 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