So I had this dll where I was using two typedefs wrapped in a namespace like so,
Constants.h
namespace constants
{
typedef int Integer;
typedef float Decimal;
}
Now the place where I was using it in the dll, I used the namespace without using the fully qualified name like using namespace constants
.
Now there was a file handler.h which was importing another utility.h which in turn was importing this constants .h
utility.h (same dll as constants.h)
#include "constants.h"
using namespace constants;
handler.h (another dll)
#include "utility.h"
#include "common.h"
The common.h here has the same Integer and Decimal typedefs defined for another data type.
As far as I know when we use using namespace constants
the typedefs scope will only be inside that translational unit, i.e here utility.h.
Hence typedefs defined in common.h was not messing up with constants typedef present in utility.h, since they were wrapped under namespace.
common.h (third dll)
typedef unsigned long int Integer
This was working fine in visual studio and the binaries were built successfully.
However on Linux I was getting
error: reference to 'Integer' is ambiguous
Why the same code is giving compiler error in Linux but not windows.
I was using Microsoft visual studio 2017,
Note : I know about the fact that we should always use namespace with fully qualifier name. But I just want to know why behaviour is different in win/unix.