Reputation: 2578
WARNING: While resolving call to function 'help' arguments were dropped!
If I compile using gcc -O3 codice -o out/codice
I get this pesky warning. It finishes compiling, so I am just wondering why this is happening.
I'm on a mac on lion with xcode 4.3 installed. The compiler it is using is i686-apple-darwin11-llvm-gcc-4.2
Note that if I switch the -O3
to -O2/-O1/-O then it continues to give the same warning
The code is as follows....
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <string.h>
#include <math.h>
void help();
char *codice_encrypt(char *in);
char *codice_decrypt(char *in);
void sigint_handler(int signal) {
exit(2);
}
int main (int argc, char **argv) {
if (argc != 3) {
help();
}
signal(SIGINT, sigint_handler);
char *ret, *status;
int tmpret;
if (strcmp(argv[1], "e") == 0 || strcmp(argv[1], "encrypt") == 0) {
status = "Encrypting...\n";
tmpret = write(STDOUT_FILENO, status, strlen((const char *)status));
ret = codice_encrypt(argv[2]);
} else if (strcmp(argv[1], "d") == 0 || strcmp(argv[1], "decrypt") == 0) {
status = "Decrypting...\n";
tmpret = write(STDOUT_FILENO, status, strlen((const char *)status));
ret = codice_decrypt(argv[2]);
} else {
status = "Could not understand command line arguments O.o\n";
tmpret = write(STDOUT_FILENO, status, strlen((const char *)status));
help(STDOUT_FILENO);
}
status = "Success!\nRetval:\n\n";
tmpret = write(STDOUT_FILENO, status, strlen((const char *)status));
tmpret = write(STDOUT_FILENO, ret, strlen((const char *)ret));
tmpret = write(STDOUT_FILENO, "\n\n", 2);
return 0;
}
void help() {
int tmpret;
const char *logo = "\n\n\t\tooooooo__oo______________________\n"
"\t\t_____oo______oo_oo_oo__oo_oo_oo__\n"
"\t\t____oo___oo__ooo_oo__o_ooo_oo__o_\n"
"\t\t___o_____oo__oo__oo__o_oo__oo__o_\n"
"\t\t_oo______oo__oo__oo__o_oo__oo__o_\n"
"\t\tooooooo_oooo_oo______o_oo______o_\n"
"\t\t_________________________________\n\n\n";
tmpret = write(STDOUT_FILENO, logo, strlen(logo));
const char *help = "Help\n"
"Is\n"
"Still\n"
"Being\n"
"Written :)\n\n";
tmpret = write(STDOUT_FILENO, help, strlen(help));
exit(1);
}
char *codice_encrypt(char *in) {
unsigned int i;
char ya = 0x55;
write(STDOUT_FILENO, "0x", 2);
char itret[50];
sprintf(itret,"%#hhx",ya);
write(STDOUT_FILENO, itret, strlen(itret));
write(STDOUT_FILENO, "\n", 1);
ya = ya & 0x0F;
ya = ya >> 1;
sprintf(itret,"%#hhx",ya);
write(STDOUT_FILENO, itret, strlen(itret));
write(STDOUT_FILENO, "\n", 1);
ya = 0x55;
ya = ya & 0xF0;
ya = ya << 1;
sprintf(itret,"%#hhx",ya);
write(STDOUT_FILENO, itret, strlen(itret));
write(STDOUT_FILENO, "\n", 1);
return in;
}
char *codice_decrypt(char *in) {
return in;
}
Thanks!
Upvotes: 0
Views: 297
Reputation: 9324
Here help() has variable number of arguments (I assume we're talking about C code). However, no arguments were passed and no arguments were read. One of optimization passes realized this and issued such a warning. Defining help() as help(void) will fix the problem.
Upvotes: 1