rmsalinas / DBow3

Improved version of DBow2
Other
501 stars 237 forks source link

static MIN_COMMON_WORDS in Database.h #27

Open NikolausDemmel opened 5 years ago

NikolausDemmel commented 5 years ago

I'm not sure why MIN_COMMON_WORDS is declared in Database.h and not the cpp file? Maybe the intention is that the library user could change this value programmatically like a parameter. This will however not work, since the the nature of static variables is that they are independent in each translation unit, so setting it from your program code will not affect the value in Database.cpp.

This is probably also the reason why you get a compiler warning like

/usr/wiss/demmeln/work/slam/ldso/LDSO/thirdparty/DBoW3/src/Database.h:31:12: warning: ‘DBoW3::MIN_COMMON_WORDS’ defined but not used [-Wunused-variable]
 static int MIN_COMMON_WORDS = 5;

every time you include Database.h.

Solution? If you want a configurable parameter, you might want to add it to the Database class as a member. If you want a constant, make it static const or else move it to the cpp file.