git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] mingw: redefine the wrapper macro after the corresponding function

From
Stepan Kasal <kasal@ucw.cz>
Date
Jun 6, 2014, 11:10 UTC
Message-ID
<20140606111028.GA1909@camelia.ucw.cz>
In-Reply-To
<53918D27.7060604@gmail.com>
Hi Karsten,
On Fri, Jun 06, 2014 at 11:43:03AM +0200, Karsten Blees wrote:
> [...] Assume all other callers are written
> 'mingw_foo', as suggested by Hannes, and no one except 'mingw_foo'
> has the need to call MSVCRT's 'foo' directly. Then its irrelevant
> whether the #undef is at the top or immediately before 'mingw_foo'.

Yet there is still danger that someone calls foo() by mistake. It is still best to have a protection: #define foo choke_here_do_not_use_this

> Thinking about this some more, the best solution is probably to
> eliminate the problem altogether by adding inline-wrappers for
> required CRT-functions, e.g.:

Yes, this is acceptable. But I wouldn't pollute mingw.h. You can do it on top of mingw.c like this:

#undef gethostname
static inline int crt_gethostname(char *host, int namelen)
{
	return gethostname(host, namelen);
}
#define gethostname please_call_the_mingw_or_crt_version

This would also be an acceptable solution, though I still prefer my solution, because, as you put it:

> Having the #undef in close vicinity of the function definition
> helps removing it when it's no longer needed.
Stepan
PS: Anyway, this is another patch which I can mark as "too much
discussion, try later."  Then I can proceed and submit your unicode
branch.
-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Previous: Karsten BleesNext: Karsten Blees
Message 10 of 11 in “mingw: redefine the wrapper macro after the corresponding function”
  1. mingw: redefine the wrapper macro after the corresponding functionStepan Kasal, Jun 5, 2014
  2. Karsten BleesJun 5, 2014
  3. Stepan KasalJun 5, 2014
  4. Karsten BleesJun 5, 2014
  5. Johannes SixtJun 5, 2014
  6. Karsten BleesJun 5, 2014
  7. Stepan KasalJun 6, 2014
  8. mingw: redefine the wrapper macro after the corresponding functionStepan Kasal, Jun 6, 2014
  9. Karsten BleesJun 6, 2014
  10. Stepan KasalJun 6, 2014
  11. Karsten BleesJun 6, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.