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 85
  • Answers 949
  • Best Answers 15
  • Users 800

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

    • 271 Answers
  • BHASKAR

    RTC IN STM32 DATE PROBLEM

    • 62 Answers
  • Tanmoy Chandra Dey

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

    • 60 Answers
  • Aditya007

    Programming Error while using PICKIT4

    • 58 Answers
  • D Sai krishna

    STM32 board is not shown in Device Manager ( Not ...

    • 53 Answers
  • sex việt f68
    sex việt f68 added an answer Nice weblog here! Additionally your website quite a bit up… June 7, 2025 at 3:22 pm
  • How Do You Play Two Handed Pinochle
    How Do You Play Two Handed Pinochle added an answer However, if your opponent bids low, you may want to… June 7, 2025 at 2:48 pm
  • https://blackcoin.co
    https://blackcoin.co added an answer If you do not wish to concede, table your natural… June 7, 2025 at 2:46 pm
  • drdavidcreel.com
    drdavidcreel.com added an answer Dianabol is a steroid that is often used for bodybuilding… June 7, 2025 at 1:39 pm
  • Maltepe Masaj Salonu
    Maltepe Masaj Salonu added an answer Hmm is anyone else having problems with the images on… June 7, 2025 at 3:41 am

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.