Menu

#35 Minor generated code fix in masearch.c

developer
closed-fixed
5
2011-05-14
2010-12-22
Tom Wallace
No

In masearch.c, the generated code has an incorrect form for the arguments of main -- main(int nargs, char **args[]) rather than main(int nargs, char **args). This doesn't hurt anything, since the routine doesn't use the arguments, but it violates the c99 standard.

Unlike the use of main without a type specifier, which also violates the c99 standard (and occurs a *lot* in the ATLAS code), the c99 compilers I'm using won't simply pass this error with a warning, but refuse to compile the generated code. The attached patch fixes this (and takes a tiny step toward c99 compliance by declaring main as int).

Discussion

  • Tom Wallace

    Tom Wallace - 2010-12-22

    Minor generated code fix in masearch.c - patch for 3.9.32

     
  • R. Clint Whaley

    R. Clint Whaley - 2010-12-23
    • status: open --> open-fixed
     
  • R. Clint Whaley

    R. Clint Whaley - 2010-12-23

    Made the args change, not the int declaration. ATLAS is not targeted to C99. When I look through ATLAS, there is a lot of mixed usage (i.e., routines I've written recently declare int main, and older files use the classic main()).

    Surely main() works in C99, since it was the *recommended* declaration in the older ANSI C?

    Thanks,
    Clint

     
  • Tom Wallace

    Tom Wallace - 2010-12-23

    The c99 standard requires int main(), although I don't know of a c99 compiler that has the guts to do anything more than emit a warning. Both of the forms allowed by c99 are also legal in c90 -- these are int main(void) and int main(int argc, char *argv[]). From the standard:

    "The function called at program startup is named main. The implementation declares no prototype for this function. It shall be defined with a return type of int and with no parameters:

    int main(void) { /* ... */ }

    or with two parameters (referred to here as argc and argv, though any names may be used, as they are local to the function in which they are declared):

    int main(int argc, char *argv[]) { /* ... */ }

    or equivalent; or in some other implementation-defined manner."

     
  • R. Clint Whaley

    R. Clint Whaley - 2011-05-14
    • status: open-fixed --> closed-fixed
     
  • R. Clint Whaley

    R. Clint Whaley - 2011-05-14

    Oh, I see what you are saying. Fixed.

    Thanks,
    Clint

     

Log in to post a comment.