Skip to content

Commit 7905174

Browse files
committed
MSVC compat - static not supported in declaration
The C99 static in array declarator in function array list (`foo(int a[static 3])`) is not supported by MSVC, which doesn't implement C99. Suprisingly, [1] states: "When you specify /std:c11 or /std:c17, MSVC supports all the features of C11 and C17 required by the standards." but this doesn't seem to be correct for this feature (MSVS 2022). [1]: https://learn.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version?view=msvc-170
1 parent ec2b40e commit 7905174

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/gpujpeg_common_internal.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@
7171
#define __func__ ""
7272
#endif // VS <=2015
7373

74+
// MSVC doesnt support `foo(int a[static 3])` syntax
75+
#if defined _MSC_VER
76+
#define STAT_ARR_DCL(c)
77+
#else
78+
#define STAT_ARR_DCL(c) static c
79+
#endif
80+
7481
/** Contants */
7582
#define GPUJPEG_BLOCK_SIZE 8
7683
#define GPUJPEG_BLOCK_SQUARED_SIZE 64

src/gpujpeg_exif.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ gpujpeg_write_ifd(struct gpujpeg_writer* writer, const uint8_t* start, size_t co
301301
* from tags remove the items that are overriden by custom_tags
302302
*/
303303
static size_t
304-
remove_overriden(size_t count, struct tag_value tags[static count], const struct custom_exif_tags custom_tags[static 1])
304+
remove_overriden(size_t count, struct tag_value tags[STAT_ARR_DCL(count)],
305+
const struct custom_exif_tags custom_tags[STAT_ARR_DCL(1)])
305306
{
306307
for ( unsigned i = 0; i < custom_tags->count; ++i ) {
307308
for ( unsigned j = 0; j < count; ++j ) {

0 commit comments

Comments
 (0)