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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:03:22+00:00 2026-05-31T23:03:22+00:00

In C, when stating extern or static specifiers on a function, what is the

  • 0

In C, when stating extern or static specifiers on a function, what is the proper syntax use –
only on declaration? on definition? both? is it the same with a variable?

Thanks!

  • 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-31T23:03:24+00:00Added an answer on May 31, 2026 at 11:03 pm

    Declaring a extern Function:

    The keyword extern should be used only while declaring(not defining) a function.Note that functions by default have external linkage so the keyword extern on a function declaration is redundant.

    extern void doSomething();
    

    Defining a extern Function:

    The function definition should not be specified with extern keyword. The definition could be in another cpp file.

    void doSomething()
    {
    }
    

    Declaring a static Function:
    A static function restricts the use of the function to the Translation Unit in which it is declared. You need to specify the keyword when you declare it.

    static void doSomething();
    

    Defining a static Function:
    The function definition needs to be defined in the same TU.You don’t need to specify the static keyword while defining it.

    void doSomething()
    {
    }
    

    Using a extern variable:
    You declare a variable as extern when you want to share the same global variable accross different translation Unit.
    You need to declare the variable with extern keyword while you need to define it in one and only one cpp file.

    file1.h

    extern int i;
    

    file1.cpp

    #include"file1.h"
    
    int i = 10;
    

    file2.cpp

    #include "file1.h"
    
    int main()
    {
        i = 40;
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code fails to compile stating A local variable named 'st' cannot be
It's quite common to have a form with a checkbox stating Use foo immediately
I'm trying to use SWIG to create a Octave function. But even the most
I am trying to call a function but I get an error stating function
Does stating <meta name=viewport content=width=device-width /> have the same effect as stating <meta name=viewport
When I try to import it gives error at the import stating method definition
I've come across several sources stating to split up a WiX installation file into
Not even sure I'm stating the question correctly. Here's the situation. I have a
Is there a way to fall through multiple case statements without stating case value:
Reading through the Flickr API documentation it keeps stating I require an API key

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.