#2 extern variables

open
nobody
None
5
2001-04-04
2001-04-04
Anonymous
No

The appending of " = {0}" to extern variables
causes trouble for nearly every compiler.
Run cproto -e and it will generate code like

extern const int foo = {0};

for const declared global variables.

Proposed patch:

*** lintlibs.c Sun Jan 18 19:49:21 1998
--- lintlibs.c.new Wed Apr 4 19:29:51 2001
***************
*** 619,629 ****
}
put_char(outf, CURL_R);
} else {
- /* SVR4 lint complains if we declare const data
w/o some initializer.
- */
- if (strkey(decl_spec->text, "const") != NULL
- || strkey(declarator->text, "const") != NULL)
- put_string(outf, " = {0}");
put_string(outf, ";");
}
put_newline(outf);
--- 619,624 ----

which is kind of radical - perhaps some check
for "extern" might be adequate...

Wolfgang

Discussion

  • Logged In: NO

    This also happens (and is especially fatal) for functions
    returning const pointers, e.g.

    const char *foobar(int v) {
    return NULL;
    }

    Generates the output:

    const char *foobar(int v) = {0};