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

  • Home
  • SEARCH
  • 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 7495495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:10:18+00:00 2026-05-29T18:10:18+00:00

The header file contains two variables. Because of the structure of my program, I

  • 0

The header file contains two variables.
Because of the structure of my program, I have two “ld: duplicate symbol” errors.
These two variables have only local significance.
Is there any way of making these variables “private”, so they wouldn’t be seen outside of the header file even if the header file is included to another source file?

EDIT: please tell me, would it be nice if I will put the variables to the cpp file? These variables are very big arrays, defined while initializing, and take a lot of lines of code…

extern char Lookup[][3] = {  "aa", "ab", "ac", "ad", "ae", "af", ... and so on (really long)}
  • 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-29T18:10:32+00:00Added an answer on May 29, 2026 at 6:10 pm

    The solution is to not define variables in your header file.

    If you absolutely must share variables between internal source files (and I recommend that you don’t), then you should do the following:

    1. Create an “internal.h”.
    2. Declare your variable extern in that header file.
    3. Include “internal.h” in both your internal source files.
    4. Define the variable in one or other internal source files.

    The variable is now hidden from the outside world. (It’s probably still visible in your object files, but you can use platform-specific trickery to strip it.)

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

Sidebar

Related Questions

I have an ANSI C program comprising two files. The first file contains the
I have four C file. Two of them are header file. 1.Const.h contains extern
I have an XML Template file. This file contains a header and some predefined
I have two .csv files containing correlation matrices exported from R. One file contains
Possible Duplicate: Why can templates only be implemented in the header file? Why should
In my game I have a header file that contains properties and functions for
My project has two cpp files and one header file. One cpp file contains
The setup: I have a standard .php file (index.php) that contains two includes, one
I have a header for a list that contains two image buttons. I want
in header file I have defined the following function #ifndef OS_H #define OS_H #include

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.