2

これは、GCCによって生成されたがMSVCによっては生成されなかった非常に奇妙なエラーを含むコードです(5つのエラー、エラー行のコメント形式で引用):

/* Match STRING against the filename pattern PATTERN, returning zero if
   it matches, nonzero if not.  */
int GNU_fnmatch (const char* pattern,const char* string,int flags)
{
    register const char *p = pattern, *n = string;
    register unsigned char c;

    #define FNM_CASEFOLD 16
    #define FNM_LEADING_DIR 8

    #define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))

    while ((c = *p++) != '\0')
    {
        c = FOLD (c);

        switch (c)
        {
        case '?':
            if (*n == '\0')
                return 1;
            else if ((flags & FNM_PATHNAME) && *n == '/')
                return 1;
            else if ((flags & FNM_PERIOD) && *n == '.' &&
                (n == string || ((flags & FNM_PATHNAME) && n[-1] == '/')))
                return 1;
            break;

        case '\\':
            if (!(flags & FNM_NOESCAPE))
            {
                c = *p++;
                c = FOLD (c);
            }
            if (FOLD ((unsigned char)*n) != c)
                return 1;
            break;

        case '*':
            if ((flags & FNM_PERIOD) && *n == '.' &&
                (n == string || ((flags & FNM_PATHNAME) && n[-1] == '/')))
                return 1;

            for (c = *p++; c == '?' || c == '*'; c = *p++, ++n)
            if (((flags & FNM_PATHNAME) && *n == '/') ||
            (c == '?' && *n == '\0'))
                return 1;

            if (c == '\0')
                return 0;

            {
            unsigned char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c;
            c1 = FOLD (c1);
            for (--p; *n != '\0'; ++n)
                if ((c == '[' || FOLD ((unsigned char)*n) == c1) &&
                GNU_fnmatch (p, n, flags & ~FNM_PERIOD) == 0)
                return 0;
            return 1;
            }

        case '[':
            {
            /* Nonzero if the sense of the character class is inverted.  */
            register int not; // Error  1   error : expected unqualified-id before '!' token

            if (*n == '\0')
                return 1;

            if ((flags & FNM_PERIOD) && *n == '.' &&
            (n == string || ((flags & FNM_PATHNAME) && n[-1] == '/')))
                return 1;

            not = (*p == '!' || *p == '^'); // Error    2   error : expected primary-expression before '=' token
            if (not) // Error   3   error : expected primary-expression before ')' token
                ++p;

            c = *p++;
            for (;;)
                {
            register unsigned char cstart = c, cend = c;

            if (!(flags & FNM_NOESCAPE) && c == '\\')
                cstart = cend = *p++;

            cstart = cend = FOLD (cstart);

            if (c == '\0')
                /* [ (unterminated) loses.  */
                return 1;

            c = *p++;
            c = FOLD (c);

            if ((flags & FNM_PATHNAME) && c == '/')
                /* [/] can never match.  */
                return 1;

            if (c == '-' && *p != ']')
                {
                cend = *p++;
                if (!(flags & FNM_NOESCAPE) && cend == '\\')
                    cend = *p++;
                if (cend == '\0')
                    return 1;
                cend = FOLD (cend);

                c = *p++;
                }

            if (FOLD ((unsigned char)*n) >= cstart
                && FOLD ((unsigned char)*n) <= cend)
                goto matched;

            if (c == ']')
                break;
                }
            if (!not) // Error  4   error : expected primary-expression before ')' token
                return 1;
            break;

            matched:;
            /* Skip the rest of the [...] that already matched.  */
            while (c != ']')
                {
            if (c == '\0')
                /* [... (unterminated) loses.  */
                return 1;

            c = *p++;
            if (!(flags & FNM_NOESCAPE) && c == '\\')
                /* XXX 1003.2d11 is unclear if this is right.  */
                ++p;
                }
            if (not) // Error   5   error : expected primary-expression before ')' token
                return 1;
            }
            break;

        default:
            if (c != FOLD ((unsigned char)*n))
            return 1;
        }

        ++n;
    }

    if (*n == '\0')
        return 0;

    if ((flags & FNM_LEADING_DIR) && *n == '/')
    /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz".  */
        return 0;

    return 1;
}

つまり、存在しないことをせがんで、それは意味がありません'!' トークン(エラー1)!!!

4

1 に答える 1

6

notはC++では予約語ですが、Cでは予約語ではありません。

エラーは自明です:

if (!not) // Error  4   error : expected primary-expression before ')' token
        ^ //expecting operand for 'not' to act on, got ')' instead.

GCCのC オプションのいずれかとコンパイルするか、名前を変更します。

于 2013-01-31T11:31:35.760 に答える