The C compiler from Sun WorkShop assumes a type int
for any function or variable that is used in a module and not defined or declared externally. Any longs
and pointers used in this way are truncated by the compiler's implicit int
declaration. The appropriate extern
declaration for the function or variable should be placed in a header and not in the C module. This header should then be included by any C module that uses the function or variable. If this is a function or variable defined by the system headers, the proper header should still be included in the code.
int main(int argc, char *argv[]) { char *name = getlogin() printf("login = %s\n", name); return (0); } % warning: improper pointer/integer combination: op "=" warning: cast to pointer from 32-bit integer implicitly declared to return int getlogin printf
Suggested use:
#include <unistd.h> #include <stdio.h> int main(int argc, char *argv[]) { char *name = getlogin(); (void) printf("login = %s\n", name); return (0); }