Tuesday, 10 September 2013

Duplicate symbol and functions with static keyword

Duplicate symbol and functions with static keyword

I want to create a Commons.h file where I can put some shared info,
constants, macros and helper functions.
This file has to be included in many part of my application.
If I create function with this syntax I get a Duplicate Symbol error:
int myFunction(int a){
//do something..
}
While if I add the static keyword I get no errors.
static int myFunction(int a){
//do something..
}
1) Is this a valid/right way to add helper functions to a project? 2) What
happen exactly adding the static keyword at that definition?

No comments:

Post a Comment