Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1029223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:30:45+00:00 2026-05-16T12:30:45+00:00

Okay, strange question time! I’m refactoring some old C++ code that declares a bunch

  • 0

Okay, strange question time!

I’m refactoring some old C++ code that declares a bunch of arrays like so:

static SomeStruct SomeStructArray[] = {
    {1, 2, 3},
    {4, 5, 6},
    {NULL, 0, 0}
}

And so forth. These are scattered about in the source files, and are used right where they’re declared.

However, I would like to move them into a single source file (mostly because I’ve come up with a way of auto-generating them). And, of course, I naively try to make a header for them:

static SomeStruct SomeStructArray[];

Actually, even I know that’s wrong, but here’s the compiler error anyway:

error C2133: 'SomeStructArray' : unknown size    arrays.h
error C2086: 'SomeStruct SomeStructArray[]' : redefinition    arrays.cpp

So, I guess, what’s the right way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:30:45+00:00Added an answer on May 16, 2026 at 12:30 pm

    If you’re going to put the arrays themselves all in one file (and apparently access them from other files) you need to remove the static from the definitions (which makes them visible only inside the same translation unit (i.e., file)).

    Then, in your header you need to add an extern to each declaration.

    Finally, of course, you’ll need to ensure that when you have an array of SomeStruct (for example), that the definition of SomeStruct is visible before you attempt to define an array of them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, next PHPExcel question. I have an HTML form that users fill out and
Okay, I'm NOT new to Objective-C but I encountered a strange bug, that i
Okay, I implemented this SO question to my code: Return True or False Randomly
Okay, so this might be kind of strange but here's the question: I have
Okay, so I've got a strange problem with the following Lua code: function quantizeNumber(i,
Okay this seems like a real noob question. I currently have a simple html
Okay this question is very simple: I have a facebook page, and a website.
okay, i'm setting up a multi-user chat system. i have a messages table, that
Okay, this is probably a very basic question; but, I'm just getting back in
Okay, I have the following PHP code to extract an email address of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.