Reputation: 3
So I literally have the simplest C++ file on the planet, and it won't compile. I can't seem to figure out where main is being defined before, is it in some weird search path? I've searched around and haven't been able to get anything working.
#include <iostream>
int main(int argv, char* argv[]) {
std::cout << "It worked!" << std::endl;
return 0;
}
When I compile this happens:
g++ -c main.cpp -O3
main.cpp:4:31: error: conflicting declaration ‘char** argv’
int main(int argv, char* argv[]) {
^
main.cpp:4:14: error: ‘argv’ has a previous declaration as ‘int argv’
int main(int argv, char* argv[]) {
^
main.cpp:4:5: warning: ‘int main(int)’ takes only zero or two arguments [-Wmain]
int main(int argv, char* argv[]) {
^
make: *** [main.o] Error 1
Upvotes: 0
Views: 74
Reputation: 542
Main function is not defined anywhere else. The parameters of the main function have same names. Change them.
Upvotes: 1
Reputation: 541
It should be:
int main(int argc, char* argv[])
Both your parameters are currently called argv.
Upvotes: 5