TheMeaningfulEngineer
TheMeaningfulEngineer

Reputation: 16329

Add a global variable to static lib for versioning?

This question related to accepted answer to this question. The answer states that you can add the version as a char somewhere in the library code.

char* library_version = { "Version: 1.3.6" };

If I was following the approach for an executable, I would just place this somewhere in the beginning of main. Where should it be placed in a library to be sure it will be executed?

Upvotes: 0

Views: 113

Answers (1)

Quicky
Quicky

Reputation: 411

In the same place than other global variables declaration.
Please notice this is a variable declaration, this is not an instruction, it will never be executed. What can be executed is a function returning this variable or comparing it with an other

Upvotes: 1

Related Questions