Skip to content

Instantly share code, notes, and snippets.

@rk76feWF
Created March 18, 2023 14:30
Show Gist options
  • Save rk76feWF/3a6122be3b493671f9adec901fa3dc52 to your computer and use it in GitHub Desktop.
Save rk76feWF/3a6122be3b493671f9adec901fa3dc52 to your computer and use it in GitHub Desktop.
prints関数
void prints(const char *format, ...)
{
va_list args;
va_start(args, format);
int length = vsnprintf(NULL, 0, format, args) + 1;
char buffer[length];
vsnprintf(buffer, length, format, args);
for (int i = 0; i < length - 1; i++)
{
while (U2STAbits.TRMT == 0)
;
U2TXREG = buffer[i];
}
va_end(args);
return;
}
@rk76feWF
Copy link
Author

xc16ではmalloc関数を使いたい場合、ヒープサイズの指定が必要っぽい。VLAなら問題なく使用できる。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment