On Tue, Oct 21, 2008 at 9:29 PM, Evan Martin <[EMAIL PROTECTED]> wrote: > > Ibrar, > > What is the return value of that function? It has the "int" but its > meaning ends up being platform-specific. I'd instead argue that there > are two cases where GetLastError shows up:
Actually I used GetLastError as an example. BTW return type is not the issue here Windows GetLastError function has return type DWORD(32bit) but most significant bits are not used so we can use int instead of DWORD http://msdn.microsoft.com/en-us/library/ms679360(VS.85).aspx Similarly errno is of type int in Linux. So at least this function will work on Windows and Linux http://www.opengroup.org/onlinepubs/009695399/functions/errno.html > 1) Places where the code is checking for specific errors, in which > case we'll need platform-specific tests as error codes vary; and Again I don't want to stick on one example here but these all checks can be handle in platform::GetLastError function. > 2) Places where the code is checking for errors in general, in which > case it may make sense to have a generic boolean-returning function > (like "DidErrorOccur"), but even then I'd prefer the code to properly > handle the error (and convert it to a more helpful string error > message). I think you did't get my point here. Whenever you write a program which is platform independent then these small function can cause problem at end if these are not written platform independently. If there is logic/design change then we can put OS macro around the code but if we have small functions call and occurrence of calls are too much then we should wrap these function. > On Tue, Oct 21, 2008 at 2:44 AM, Ibrar Ahmed <[EMAIL PROTECTED]> wrote: >> >> Hi All, >> >> While porting some module on Linux I feel that there are lot of >> Windows specific call exists. IMHO we should at least wrap these >> function with OS macros and bound further development to use that >> functions. This will really reduce the porting effort on different >> OS, because whenever you start porting a module you should wrap that >> function first and then do actual function. This looks like a >> mechanical work and totally waste of time. >> >> Here is the example what I want to state here. >> >> We are using GetLastError() function almost 100+ times. So it Should >> looks like this >> >> Calling >> ==== >> platform::GetLastError(); >> >> >> Function >> ===== >> namespace platform (or any other name) >> { >> >> int GetLastError() >> { >> #if defined(OS_WIN) >> return GetLastError(); >> #elif defined(OS_POSIX) >> return errno; >> #endif >> } >> >> } >> >> >> Comments? >> >> -- >> Ibrar Ahmed >> EnterpriseDB http://www.enterprisedb.com >> >> > >> > > > > -- Ibrar Ahmed EnterpriseDB http://www.enterprisedb.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Chromium-dev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/chromium-dev?hl=en -~----------~----~----~----~------~----~------~--~---
