Re: [PATCH] git-compat-util: Avoid strcasecmp() being inlined
- From
Sebastian Schuberth <sschuberth@gmail.com>
- Date
- Sep 12, 2013, 09:36 UTC
- Message-ID
- <CAHGBnuP3iX9pqm5kK9_WjAXr5moDuJ1jxtUkXwKEt2jjLTcLkQ@mail.gmail.com>
- In-Reply-To
- <20130911214116.GA12235@sigill.intra.peff.net>
On Wed, Sep 11, 2013 at 11:41 PM, Jeff King <peff@peff.net> wrote:
Show 12 quoted lines
>> I'm on Windows using MSYS / MinGW. Since MinGW runtime version 4.0,
>> string.h contains the following code (see [1]):
>>
>> #ifndef __NO_INLINE__
>> __CRT_INLINE int __cdecl __MINGW_NOTHROW
>> strncasecmp (const char * __sz1, const char * __sz2, size_t __sizeMaxCompare)
>> {return _strnicmp (__sz1, __sz2, __sizeMaxCompare);}
>> #else
>> #define strncasecmp _strnicmp
>> #endif
>
> What is the error the compiler reports? Can it take the address of otherThe error message of GCC 4.8.1 is:
LINK git-credential-store.exe libgit.a(mailmap.o): In function `read_mailmap': C:\mingwGitDevEnv\git/mailmap.c:238: undefined reference to `strcasecmp' collect2.exe: error: ld returned 1 exit status make: *** [git-credential-store.exe] Error 1
So it's a linker error, not a compiler error.
Show 5 quoted lines
> inline functions? For example, can it compile:
>
> inline int foo(void) { return 5; }
> extern int bar(int (*cb)(void));
> int call(void) { return bar(foo); }I had to modify the example slightly to:
inline int foo(void) { return 5; } extern int bar(int (*cb)(void)) { return cb(); } int main(void) { return bar(foo); }
And this compiles.
> Just wondering if that is the root of the problem, or if maybe there is > something else subtle going on. Also, does __CRT_INLINE just turn into > "inline", or is there perhaps some other pre-processor magic going on?
This is the function definition from string.h after preprocessing:
extern __inline__ int __attribute__((__cdecl__)) __attribute__ ((__nothrow__))
strncasecmp (const char * __sz1, const char * __sz2, size_t __sizeMaxCompare)
{return _strnicmp (__sz1, __sz2, __sizeMaxCompare);}-- Sebastian Schuberth