Debug点击三次run才能运行,直接烧录后无法运行/重上电也不行
纯C可以勾选“Use MicroLIB”
C/C++混合,勾选“Use MicroLIB”会报错,需换如下方式:
#define unprintf(...) utnprintf(&huart1, __VA_ARGS__)
#define uprintf(...) utnprintf(&huart1, 1024, __VA_ARGS__)
inline int utnprintf(UART_HandleTypeDef *huart, int bufsz, const char *__restrict format, ...) { if(bufsz<0 || bufsz>65536){return -1;} int ret; va_list ap_uprtf; va_start(ap_uprtf, format); if(bufsz == 0){ ret = vsnprintf(NULL, 0, format, ap_uprtf); va_end(ap_uprtf); return ret; } char buffer[bufsz]; ret = vsnprintf(buffer, bufsz, format, ap_uprtf); va_end(ap_uprtf); if(ret > 0){ if(ret < bufsz){bufsz = ret;} else{--bufsz;} MyPrintf(buffer, bufsz); //输出 } return ret; }
标签:__,va,定义,ap,ret,uprtf,bufsz,printf,print From: https://www.cnblogs.com/boring-luobo/p/17874249.html