Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

What is the array size?

Posted on 2013-06-24
1
Medium Priority
?
293 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 1600 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

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