Error collecting va_list value in C

Asked

Viewed 31 times

1

Good afternoon. I came across a problem at the time of preparing the 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 begins in 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, except for the name only, the _sqlite3_insert method works normally, 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*);

Would anyone know why and how I can solve this problem? Obg.

  • It would be watering that you show the parts different code. Show equal parts makes it difficult to find the differences!

1 answer

2


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

  • That’s right, now it worked perfectly. vlw

Browser other questions tagged

You are not signed in. Login or sign up in order to post.