I am currently designing an API where I want that the user to be able to write code like this:
PowerMeter.forceVoltage(1 mV);
PowerMeter.settlingTime(1 ms);
I prefer avoiding macros where ever I can, and this is an example where it should be possible. One lightweight solution that gives you correct dimensions would be:
static double m = 1;
static double cm = 0.1;
static double mV = 0.001;
double distance = 10*m + 10*cm;
This also reflects the physical concept that units are something that's multiplied with the value.