I would like to use external variables as parameters in several c++ files. How do I use a namespace with external vars? Without the namespace everything works.
crack_detection_opencv.cpp:-1: In function ‘void ProcessArgs(int, const char**)’:
fillSobelSearchSize = std::stoi(optarg);
reference to ‘fillSobelSearchSize’ is ambiguous
Shortened code:
void ProcessArgs(int argc, const char** argv_orig)
{
fillSobelSearchSize = std::stoi(optarg);
}
#pragma once
namespace cd
{
float contrastAlpha = 5.8f; //unused
float contrastBeta = -2.8f; //unused
float contrastAlpha2 = 5.6f; //unused
float contrastBeta2 = -2.8f; //unused
int fillSobelSearchSize = 20;
}
using namespace cd;
extern float contrastAlpha;// = 5.8f;
extern float contrastBeta;// = -2.8f;
extern float contrastAlpha2;// = 5.6f;
extern float contrastBeta2;// = -2.8f;
extern int fillSobelSearchSize;
I tried to use external global variables as parameters in several functions and wrap them in a namespace. Without the namespace it works fine, but there are compilation erros if I use a namespace.