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

Re: [PATCH] Fix a warning (on cygwin) to allow -Werror

From
Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Date
Aug 28, 2008, 16:09 UTC
Message-ID
<48B6CD9F.6020302@ramsay1.demon.co.uk>
In-Reply-To
<48B508F0.70402@viscovery.net>
Johannes Sixt wrote:
Show 11 quoted lines
> Ramsay Jones schrieb:
>> Also, I noticed that git_ntohl() is still defined in compat/mingw.h; is this
>> still required?  It's not a problem, just curious! (I don't have mingw
>> installed, so I can't test myself)
> 
> Yes, it's still needed. The reason is that on Windows ntohl() returns
> 'unsigned long', and then gcc warns about
> 
> sha1_file.c:700: warning: unsigned int format, u_long arg (arg 3)
> 
> git_ntohl() is the workaround.
OK, Thanks.
Ah, yes, everything works on cygwin and Linux because:
                             Linux           Cygwin
    ntohl() returns:         uint32_t        uint32_t
    uint32_t typedef-ed as:  unsigned int    unsigned long
    PRIu32 #define-d as:     "u"             "lu"
So, I suspect (IOW I am guessing that) mingw must have:
    ntohl() returns:         unsigned long (well u_long anyway)
    uint32_t typedef-ed as:  unsigned int
    PRIu32 #define-d ad:     "u"

(I've just noticed that you are not #include-ing inttypes.h, so you are relying on the PRIu32 defined in git-compat-util.h)

If the above is true, then well, ... Bummer ;-)

I suppose a (very) slight improvement would be to change the return type of your git_ntohl() wrapper to uint32_t. (But we are talking very slight ;-)

ATB,
Ramsay Jones
Previous: Johannes SixtNext: Johannes Sixt
Message 3 of 4 in “Fix a warning (on cygwin) to allow -Werror”
  1. Fix a warning (on cygwin) to allow -WerrorRamsay Jones, Aug 26, 2008
  2. Johannes SixtAug 27, 2008
  3. Ramsay JonesAug 28, 2008
  4. Johannes SixtAug 29, 2008

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.