Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!tavi!gwydion From: gwydion@tavi.rice.edu (Basalat Ali Raja) Newsgroups: comp.windows.ms Subject: Re: A puzzling query Message-ID: <2836@kalliope.rice.edu> Date: 13 Mar 89 23:53:30 GMT References: <227@cbnewsc.ATT.COM> Sender: usenet@rice.edu Reply-To: gwydion@tavi.rice.edu (Basalat Ali Raja) Lines: 23 In article <227@cbnewsc.ATT.COM> foz@cbnewsc.ATT.COM (The fozman) writes: > ReleaseDC(hDC, hWnd); >instead of: > ReleaseDC(hWnd, hDC); > >Now I think both HWND and HDC are 16 bit addresses but shouldn't the compiler >spit this out as a parameter order error? An enquiring mind would like >to know...... I'm afraid this is a quirk of the language rather than that of the compiler. The types HDC and HWND are defined, quite simply, as: typedef int HWND; typedef int HDC; /* Actually, it might be unsigned int, Anyway... */ This means that HWND and HDC become synonyms for type int. That's all. So, whenever the compiler sees a HWND, it replaces it with an int. Ditto for int. Thus, it is not possible to catch the error, since both HWND and HDC are synonyms for the same thing. I, for one, think that if MicroSoft decided to extend the language definition to allow for better type-checking, it would be a good idea. Any comments? (Other than from the language purists :-] ).