Skip to content

Commit

Permalink
[msvc][platform] Use literal buf-size in C code
Browse files Browse the repository at this point in the history
C (other than C++) does not even allow const variables in array sizes.
  • Loading branch information
grandchild committed Jun 28, 2024
1 parent f762ab1 commit 483b227
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions avs/platform_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,18 @@ void mem_mark_rwx(void* block, size_t length) {
/* errors */

void print_last_system_error() {
const size_t buffer_size = 1024;
char buffer[buffer_size];
#define SYSTEM_ERR_BUFFER_SIZE 1024
char buffer[SYSTEM_ERR_BUFFER_SIZE];
if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
0,
GetLastError(),
0,
buffer,
buffer_size,
SYSTEM_ERR_BUFFER_SIZE,
NULL)) {
printf("Format message failed with 0x%lx\n", GetLastError());
return;
}
printf("!! %s", buffer);
#undef SYSTEM_ERR_BUFFER_SIZE
}

0 comments on commit 483b227

Please sign in to comment.