[tex-k] Issues with CTANGLE

Doug McKenna doug at mathemaesthetics.com
Tue May 26 02:16:08 CEST 2020


ctangle.w contains the lines:

   @<Predecl...@>=
   extern int strlen(); /* length of string */

But a quick compilation of the tangled version of ctangle.w issues a warning about this (on my system, MacOS), because all the headers declare strlen() (and similar) as returning an integer of type |size_t|, which on an LP64 architecture is an unsigned 64-bit long, whereas an |int| is still 32-bits.

Compiling strlen() as returning an 32-bit |int| while linking to a strlen() in an external library that returns an unsigned 64-bit long could end up being a bug.

Plus the C code has a whole lot of elided |int| type declarations, all in accord with ancient and possibly deprecated syntax.  The set of warnings I get is:

cc ctangle.c

common.h:123:8: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
extern history;
~~~~~~ ^
common.h:124:8: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
extern err_print();
~~~~~~ ^
common.h:125:8: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
extern wrap_up();
~~~~~~ ^
common.h:138:8: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
extern include_depth;
~~~~~~ ^
common.h:148:8: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
extern line[];
~~~~~~ ^
common.h:149:8: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
extern change_line;
~~~~~~ ^
common.h:150:8: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
extern change_depth;
~~~~~~ ^
common.h:154:8: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
extern reset_input();
~~~~~~ ^
common.h:155:8: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
extern get_line();
~~~~~~ ^
common.h:156:8: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
extern check_complete();
~~~~~~ ^
ctangle.w:78:12: warning: incompatible redeclaration of library function 'strlen'
      [-Wincompatible-library-redeclaration]
extern int strlen();
           ^
ctangle.w:78:12: note: 'strlen' is a builtin with type 'unsigned long (const char *)'
ctangle.w:955:1: warning: add explicit braces to avoid dangling else [-Wdangling-else]
else compress(minus_gt);break;
^
12 warnings generated.

FWIW,


Doug McKenna


More information about the tex-k mailing list.