Preferred run-time platform detection method (EMX/G120)

But this code if wrong as it uses an invalid pin. Sorry i am still not sure what the issue is.

The discussion topic is the preferred method to determine which platform the code is running on. The consensus view seemed to be that there is no preferred method, just use what works for you.

One method was to access an IO pin that only exists on one platform. On a different platform it will be an invalid pin, as you say, and the constructor code will throw an exception. We set a flag to tell us the host platform based on whether we catch that exception or not.

All well and good, and this works fine. However if we have taken the exception due to the invalid pin (ie we are on EMX and not G120) then at some later stage when the GC runs, it also takes an exception. This is telling us that somewhere in the constructor code for the OutputPort class there is a error, and although the constructor failed and took an exception, it did not clean up correctly after itself.

So, we know there is a coding error, but we also know how to work around it. I would now say that this is one technique that is not a preferred one for determining the host platform!

Whether the problem in the failed constructor code is an[em] issue [/em]is up to you, but I think you probably have a lot more constructive things to work on!

What we suggested is to use the system clock as this is not likely to bee the same.

Yes, I put the updated code for that at the bottom of
http://www.ghielectronics.com/community/forum/topic?id=11908&page=2#msg124244