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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:09:55+00:00 2026-06-14T02:09:55+00:00

AFAIK, any declaration of a variable or a function in file scope has external

  • 0

AFAIK, any declaration of a variable or a function in file scope has external linkage by default. static mean “it has internal linkage”, extern — “it maybe defined elsewhere”, not “it has external linkage”.

If so, why we need extern keyword? In other words, what is difference between int foo; and extern int foo; (file scope)?

  • 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-06-14T02:09:57+00:00Added an answer on June 14, 2026 at 2:09 am

    The extern keyword is used primarily for variable declarations. When you forward-declare a function, the keyword is optional.

    The keyword lets the compiler distinguish a forward declaration of a global variable from a definition of a variable:

    extern double xyz; // Declares xyz without defining it
    

    If you keep this declaration by itself and then use xyz in your code, you would trigger an “undefined symbol” error during the linking phase.

    double xyz; // Declares and defines xyz
    

    If you keep this declaration in a header file and use it from several C/C++ files, you would trigger a “multiple definitions” error during the linking phase.

    The solution is to use extern in the header, and not use extern in exactly one C or C++ file.

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

Sidebar

Related Questions

AFAIK, extern keyword should be used for declaration and no value can be associated
AFAIK when reducing an array we can only output once variable at the end
Possible Duplicate: JavaScript: var functionName = function() {} vs function functionName() {} AFAIK, there
This question is about the public key that every .NET assembly has AFAIK (looking
The program below prints: my name is:null my name is:null Someclass static init AFAIK
So AFAIK in CPython, function definitions are compiled into function objects when executed at
AFAIK : and , or are boolean operators and any boolean expression should return
Are they any library to do so? AFAIK dataToURL('image/gif') isn't supported by any browser
AFAIK: C++ provides three different types of polymorphism. Virtual functions Function name overloading Operator
Why this code allows user do not enter any text? AFAIK + means One

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.