我有带有可变参数的 myPrintf()。当我直接使用它时,everythink 工作正常。但是当我尝试从另一个可变参数函数调用它时,我得到了奇数值。我做错了什么?我还需要调用这两个函数,如下所示
myPrintf("%i %+.0f %+.0f %+.0f %+.0f %+.0f %+.0f %+.0f\n",millis(),ax,ay,az,temp,gx,gy,gz); // working
LOGSD("%i %+.0f %+.0f %+.0f %+.0f %+.0f %+.0f %+.0f\n",millis(),ax,ay,az,temp,gx,gy,gz); // not working
void LOGSD(const char *format, ...){
va_list arg;
va_start(arg, format);
myPrintf(format,arg);
va_end(arg);
return;
}
void myPrintf(const char *format, ...){
// some code here
}
example from calling myPrintf():
413137 -1112 -420 +15952 +3726 -15 +201 +90
413237 -1168 -364 +15924 +3730 -17 +206 +95
413337 -1044 -452 +15932 +3722 -37 +200 +97
413437 -1152 -360 +15876 +3732 -20 +213 +99
413537 -1120 -352 +15884 +3706 -28 +225 +96
413637 -1136 -336 +15864 +3733 -35 +214 +109
413737 -1092 -372 +15968 +3725 -35 +212 +73
413838 -1052 -340 +15808 +3721 -40 +247 +103
example from calling LOGSD():
1073451856 +0 +0 -1060 -328 +0 +2 +0
1073451856 +0 +0 -1064 -364 +2 +2 +0
1073451856 +0 +0 -1056 -400 +2 +2 +0
1073451856 +0 +0 -1132 -408 +2 +2 +0
1073451856 +0 +0 -1008 -372 +2 +2 +0
1073451856 +0 +0 -1096 -376 +2 +2 +0
1073451856 +0 +0 -1132 -296 +0 +2 +0
1073451856 +0 +0 -1148 -372 +0 +2 +0