Error collecting value from va_list in C

1

Good afternoon. I encountered a problem when preparing va_list in c. of two similar codes, one works and the other persists in error.

extern bool _sqlite3_insert(const char *table, const char *types, ...){
    M_HEADER; // macro com as variáveis data, argv e swap
    // data é char [2][500], swap é char [500] e argv é uma va_list

    va_start(argv,types);
    clear(data[0]);
    clear(data[1]);

    while(types && *types){
        swap = va_arg(argv, char *);

        if(find_quots(swap))
            return false;
        ...
    }
    ...
}

So far so good ... the error starts with this method.

extern bool _mysql_insert(const char *table, const char *types, ...){
    M_HEADER; // macro com as variáveis data, argv e swap
    // data é char [2][500], swap é char [500] e argv é uma va_list

    va_start(argv,types);
    clear(data[0]);
    clear(data[1]);

    while(types && *types){
        swap = va_arg(argv, char *);

        if(find_quots(swap))
            return false;
        ...
    }
    ...
}

As you can see, both methods are identical, with difference only in the name, the _sqlite3_insert method, it works normal, but in the _mysql_insert method, the error occurs in swap = va_arg(argv, char *)

The compiler error is as follows:

src/mysql_conn.c:20:23: error: expected expression before ‘char’
swap = va_arg(argv, char*);

Can anyone tell me why and how can I solve this problem? Obg.

    
asked by anonymous 19.02.2016 / 20:57

1 answer

2

Check that in the version with _mysql_insert() you have #include <stdarg.h> .

    
19.02.2016 / 21:44