Skip to content

Resolve some compiler warnings

  • The use of signed char is generating some warnings when building with clang with the verbosity cranked up. Changing to a plain char seems to work fine, and seems preferable to a cast, in my opinion.
  • I also replaced an int with a size_t to match sizeof().
  • I can't find my older copies of the C standard, but §5.1.2.2.1 of the C99 and C11 standard permits you to omit unused argc and argv variables from main. I'm pretty sure that was there in the 1990 ANSI standard as well.

Example:

compile.c:195:11: warning: passing 'signed char *' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
    fgets(INLINE + 1, sizeof(INLINE) - 1, OPENED);
          ^~~~~~~~~~
/usr/include/stdio.h:622:38: note: passing argument to parameter '__s' here
extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
                                     ^
compile.c:203:34: warning: array subscript is of type 'char' [-Wchar-subscripts]
      INLINE[i] = ascii_to_advent[val];
                                 ^~~~
compile.c:200:21: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
  for (int i = 1; i <= sizeof(INLINE) && INLINE[i] != 0; ++i)
                  ~ ^  ~~~~~~~~~~~~~~
compile.c:533:8: warning: explicitly assigning value of variable of type 'int' to itself [-Wself-assign]
  argc = argc;
  ~~~~ ^ ~~~~
compile.c:534:8: warning: explicitly assigning value of variable of type 'char **' to itself [-Wself-assign]
  argv = argv;
  ~~~~ ^ ~~~~
5 warnings generated.```

Merge request reports