Microcontroller Embedded C Programming Lecture 40| ‘Extern’ storage class specifier

  • Post author:
  • Post category:Blog

 

‘Extern’ storage class specifier

 

 

In this article, let’s understand extern keyword.

In C, the ‘extern‘ storage class specifier is used to declare a variable or function that is defined in another file or translation unit within the same program. It serves as a way to extend the visibility and accessibility of variables and functions across multiple files, allowing them to be used in a modular and organized manner.

We already used this extern keyword in our previous example. But let’s know some points about the extern keyword.

  • ‘extern’ storage class specifier is used to access the global variable, which is defined outside the scope of a file.
  • ‘extern’ storage class specifier can also be used during the function call, when the function is defined outside the scope of the file. 

Here, in this case, mentioning the extern keyword is not compulsory. It is optional. As we saw in the previous example, extern is assumed when you try to call a function which is outside the scope of that file. 

  • The keyword ‘extern’ is relevant only when your project consists of multiple files, and you need to access a variable defined in one file from another file. 

So, it makes sense only when you have multiple files. Otherwise, you need not use ‘extern.’

  • ‘extern’ keyword is used to extend the visibility of a function or variable.

That’s about the ‘extern’ keyword.

 

Get Microcontroller Embedded C Programming Full Course Here

FastBit Embedded Brain Academy Courses

Click here: https://fastbitlab.com/course1

 

FastBitLab

The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.

Leave a Reply