Sign Up

Unlock the Gateway: Join the Embed Threads

Have an account? Sign In

Captcha Click on image to update the captcha.

Have an account? Sign In Now

Sign In

Unlock the Possibilities: Dive In with Login Access

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

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

Embed Threads

Embed Threads

Embed Threads Navigation

  • Blogs
  • Forum
  • About Us
  • Contact Us
  • Books
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Forum
  • Communities
  • Questions
    • New Questions
    • Must Read Questions
    • Trending Questions
    • Hot Questions
  • Polls
  • Groups
  • Add group
  • Badges
  • Users
  • Help
  • Blogs
  • Forum
  • About Us
  • Contact Us
  • Books

Shashank

Beginner
Ask Shashank
18 Visits
0 Followers
0 Questions
  • About
  1. Asked: July 6, 2023In: Embedded Software Development

    Use of static variable declaration in a header file included in multiple .c files

    Shashank Beginner
    Added an answer on July 10, 2023 at 5:23 am

    Here we declare variable as a global scope. If a variable is declared as static at the global scope within a header file (.h file) that is included in multiple .c files, each translation unit (.c file) will have its own private copy of that variable. This means that each file that includes the headeRead more

    Here we declare variable as a global scope.
    If a variable is declared as static at the global scope within a header file (.h file) that is included in multiple .c files, each translation unit (.c file) will have its own private copy of that variable. This means that each file that includes the header will have its own independent instance of the variable, even though they have the same name.

    However, it’s worth noting that including a header file with static variables in multiple translation units can lead to a waste of memory, as each file will have its own separate copy. In general, it is considered best practice to avoid defining variables in header files and instead declare them as extern in the header and define them in a single source file to maintain a single instance of the variable

    See less
    • 1
    • Share
      Share
      • Share onFacebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp

Sidebar

Ask A Question

Stats

  • Questions 80
  • Answers 2k
  • Best Answers 15
  • Users 801

Free PDF Downloads

A Roadmap to a Successful Career

HTTP, WS and TLS: The Complete Guide

Embedded Interview Questions

  • Popular
  • Answers
  • alokm014

    Embedded System Testing: Strategies and Approaches

    • 856 Answers
  • Sri Bathran S

    Roadmap to embedded software developer

    • 293 Answers
  • Aditya007

    Programming Error while using PICKIT4

    • 212 Answers
  • Kushal KJ

    FreeRTOS_config.h file for STM32F401RE Nucleo Board

    • 167 Answers
  • Tanmoy Chandra Dey

    Why is the "ADDR flag" cleared without reading the SR2

    • 115 Answers
  • трипскан
    трипскан added an answer What i don't realize is actually how you are not… August 2, 2025 at 1:54 am
  • Islamabad Escorts
    Islamabad Escorts added an answer For a night of excitement and enjoyment, choose from the… August 2, 2025 at 12:20 am
  • ufabet
    ufabet added an answer Can you tell us more about this? I'd want to… August 1, 2025 at 8:26 pm
  • https://gpluck.co.uk
    https://gpluck.co.uk added an answer caesars casino References: real vegas casino (https://gpluck.co.uk) August 1, 2025 at 5:12 pm
  • www.arbaeentube.com
    www.arbaeentube.com added an answer mahjongg dimensions more time References: midas audio (www.arbaeentube.com) August 1, 2025 at 5:11 pm

Explore

  • Forum
  • Communities
  • Questions
    • New Questions
    • Must Read Questions
    • Trending Questions
    • Hot Questions
  • Polls
  • Groups
  • Add group
  • Badges
  • Users
  • Help

Footer

Embed Threads

Embed Threads

Join us on a transformative journey where knowledge is amplified and solutions are empowered.

About Us

  • Blogs
  • Forum
  • About Us
  • Contact Us
  • Books

Legal Stuffs

  • Privacy Policy
  • Adsense Disclaimer

Help

  • Help
  • Contact Us

Follow

© 2024 Embed Threads. All Rights Reserved
With Love by Embed Threads.