Tag Archives: static

Static and Dynamic Libraries on Linux

A Quickstart Guide

We’re going to look at how to create and use libraries on Linux and try to gain some insight on how libraries work behind the scenes.

Decisions Decisions!

Often when working with 3rd party code you may be limited on the options available. Some well known open-source projects have dual-licensed binaries that dictate different terms for static or dynamic linking.

Writing a library is a good way to provide an interface to customers, get code reuse and can be […]

Posted in Linux | Tagged , , , , , | Leave a comment

Scope and Lifetime of Variables in C

Niall Cooling

Director at Feabhas Limited
Co-Founder and Director of Feabhas since 1995.
Niall has been designing and programming embedded systems for over 30 years. He has worked in different sectors, including aerospace, telecomms, government and banking.
His current interest lie in IoT Security and Agile for Embedded Systems.

In a previous posting we looked at the principles (and peculiarities) of declarations and definitions. Here I would like to address the concepts of scope and lifetime of variables (program objects to be precise).

In the general case:

The placement of the declaration affects scope
The placement of the definition affects lifetime


The lifetime of an object is the time in which memory is reserved while the program is executing. There are three object lifetimes:


Given the following piece of code:

int global_a;       /* tentative defn; […]

Posted in C/C++ Programming | Tagged , , , | 6 Comments