I was using an older version of visual studio before and now I switched to visual studio 2012 and I'm getting an error in my code. It says:
error C2146: syntax error : missing ')' before identifier 'r'
How can I fix it...I've been looking for a solution for a very long time. The error is in the first line of the code...
template <class T1, class T2> inline void va_copy(T1& r, const T2& v)
{
r[0] = v[0];
r[1] = v[1];
r[2] = v[2];
}
va_copy
is a macro defined in stdarg.h
and that's the reason why you're getting that error. You can prevent the preprocessor from expanding the macro by adding a pair of parenthesis ()
to the function name
#include <iostream>
#include <stdarg.h>
template <class T1, class T2> inline void (va_copy)(T1& r, const T2& v)
{
r[0] = v[0];
r[1] = v[1];
r[2] = v[2];
}
int main() {
int a[] = { 32, 33, 34 };
const int b[] = { 22, 23, 24 };
(va_copy)(a, b);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.