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 7458365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:26:16+00:00 2026-05-29T13:26:16+00:00

I have to define a large array (lookup table) in a code. It contains

  • 0

I have to define a large array (lookup table) in a code.
It contains 256 elements and takes nearly 1 computer screen.

There are two functions that are using this array.
I want to define this array under functions, so I could access them very quickly during development.

But if I try to do it inside one file, compiler will give “Undeclared identifier” errors around functions – because they use array.

So, I must put the functions and the array to separate files.

Here is the structure of my program:

main.cpp:

#include "lookup.h"

...uses two functions...

–

lookup.h:

#ifndef SubMaster_lookup_h
#define SubMaster_lookup_h

void func1(void);
void func2(void);

char LookupTable[][3]={ "00", "01", "02" "03", "04", "05", "06", "07", "08", "09",
"0a", "0b", "0c", "0d", "0e", "0f", "00", "01", "02" "03", "04", "05", "06", "07",
"08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", and so on...}

–

lookup.cpp:

#include "lookup.h"

void func1() {
   ...body of func1...
}

void func2() {
   ...body of func2...
}

The following structure gives me “ld: duplicate symbol _LookupTable” during build.
Is there any way to change the structure, so it will not give errors?

  • 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-29T13:26:17+00:00Added an answer on May 29, 2026 at 1:26 pm

    Two ways:

    • Declare the array in the header and define it in a cpp file
    • Make it static. But this is pretty nasty (each translation unit will get its own copy)

    Try this:

    lookup.h
    extern char LookupTable[][3];
    
    lookup.cpp
    #include "lookup.h"
    
    char LookupTable[][3] = ...
    

    This answer is good.

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

Sidebar

Related Questions

I have a very large array which must be 262144 elements in length (and
if for example i have : #define PRINT(x) fprintf(stderr, x); and in code i
I have a define: hashdefine kPingServerToSeeIfInternetIsOn http://10.0.0.8 then in code I with to use
In my database I have tables that define types for example Table: Publication Types
I have some code that is crashing in a large system. However, the code
My code that I have is quite large and complicated so I won't waste
I want to be able to have a large master array and refer to
I have this macro code, which allows me to define both a C enum
I have a very large graph stored in a single dimensional array (about 1.1
I'm porting code that uses a very large array of floats, which may trigger

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.