umm okay I've tried several simple basic programs like hello world type junk and I always get the same
Invalid Argument
ld returned 1 exit status
error whenever I try to compile. Therefore, I can conclude that I probably forgot to set up a program setting correctly. Can anyone please give me some help?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well, we can help a little more if you post full compile log. Its on the tab labeled "Compile Log", and the right mouse button brings up the copy menu.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Please post the full log starting from the beginning, do not excerpt the errors. It would also be useful to know what version number of Dev you are using.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2006-04-10
The invalid argument it is talking about is nothing to do with the code. It is an argument being passed to the linker during the build. All the arguments being passed appear of the build command line which is logged in the 'Compile Log'. We can do nothing further until you post that text (in full).
This requirement is 'mentioned' in the thread titled "<-PLEASE READ BEFORE POSTING A QUESTION" which of course you read?!
Clifford.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
int main(int nnumberofargs, char* pszargs[])
{
// display instructions & ask for name
string name;
cout << "Welcome to the Name-a-nezator 2000!/n Please enter your name: ";
cin >> name;
// ask to verify
bool verify;
cout << "Are you sure your name is ";
cout << name;
cout << "? (True or False)";
cin >> verify;
}
switch(verify)
{
case True:
cout << name
cout << " will die in seven days..../n/n Thanks for using the Name-a-nezator 2000!" << endl;
system("pause");
return 0;
case False:
cout << "Please enter your REAL name!";
continue;
default:
cout << "Please enter a True or False value next time!"
continue;
}
E:/cpp-saves/namethingy.cpp:26: ISO C++ forbids declaration of system' with no
type
E:/cpp-saves/namethingy.cpp:26:int system' redeclared as different kind of
symbol
E:/Dev-Cpp/include/stdlib.h:373: previous declaration of int system(const
char*)'
E:/cpp-saves/namethingy.cpp:26: invalid conversion fromconst char*' to int'
E:/cpp-saves/namethingy.cpp:27: parse error beforereturn'
Execution terminated
I've looked through and there seems to be no problems.... What's wrong
If at any time you wish me to just shut the hell up, please say so...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yeah, it's a different computer, but I'm running it off my portable hard drive and all these school computers have the same crap anyway.
Maybe a bit of background knowledge would help here. I'm learning C++ from (here it comes)
C++ for Dummies. I decided to switch back to the old version of Dev-C++ because it's the one they include with the book. According to the book, the Include files for this version of dev-c++ don't end in .h (only very old-fashioned programmers use .h according to them, lol)
But anyway I did try the
include<stdlib.h>
command and I get the same errors, parse error before 'switch' and such.
My goal is to make a crappy 2D RPG by the end of the year (using directx... which I have no idea how to reference yet...) and I really could use some help with basics.
Thanks so much for putting up with my problems!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2006-04-11
There is nothing wrong with either <cstdlib> or <stdlib.h>. You need to read the error messages from the top. The first message:
E:/cpp-saves/namethingy.cpp:21: parse error before `switch'
Indicates that the compiler no longer regards the code as valid at that point. Just before that line you have a closing brace( } ), that terminated teh main() function. All the rest of the code is then outside of any function, and in that context makes no sense.
Always address the first reported error first, then consider if the others are 'cascaded' from the first, or separate issues. If in doubt, just re-compile.
You really should use 4.9.9.2, that is what most of the people that can help you here are using, so it helps if they need to reproduce your error.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm on the IRC support channel at #bloodshed that no one uses according to the title... Can someone join up there and talk me through some of the basic syntax and errors?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2006-04-12
Are we talking about the same code you posted above? You should probably start more than one thread, you seem to have started several different subjects in one thread.
Please also sign your threads with a distinct moniker (or create a Sourceforge login); it is not always clear that we are talking to the same person - especially as you keep changing the subject!
The benefit of having problems discussed in this forum is that it benefts the whole community, and the information remains available for reference. IRC is more transient, and benefits very few. This is the place to get your problems solved.
If you are talking about the code posted earlier, then it does have mre problems that the stray brace I mentioned. Reading and understanding teh error messages is a skill you need to learn, they are your first source of help. If you are havig problems understanding them, post the log. If you provide god quality information - such as what version you are using today ;) , the compile log and commented code - then you will generally get a fast response from here.
With respect yo your earlier code, after removing the stray brace:
The only values a bool type can take are true (non-zero), or false (zero). Values True and False (capitalised) are not defined - C++ is case sensitive).
If you ask the user to type True or False and assign the response to a bool, what do you expect t happen? The only response that I'd like to guarantee the result for are numeric values - zero for false, or non-zero for true. If the user types non-numeric text, I am not sure what will happen, probably always fales, always true, or undefined.
bool is a numeric type, not a string type. If you want to accept a text response, you need to use a string class object. You can't then use switch, that is only valid for integer types. If it works for bool, that is probably only because of an implicit cast to int.
Switching on a bool type!? What's the point? It only has two possible states, the default case is unreachable if you have a true and false case. A simple if-else construct will deal with a boolean value.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just started C++ programming today and already I have a problem I can't get past. I keep getting this
Invalid Argument
ld returned 1 exit status
error when I try to compile. My code is nothing more complicated than:
// test math program
include <cstdio>
include <cstdlib>
include <iostream>
using namespace std;
int main(int nnumberofargs, char* pszargs[])
{
// enter temp in celsius
int celsius;
cout << "Enter the temp in Celsius: ";
cin >> celsius;
}
Can someone help please?
UPDATE >> lol
umm okay I've tried several simple basic programs like hello world type junk and I always get the same
Invalid Argument
ld returned 1 exit status
error whenever I try to compile. Therefore, I can conclude that I probably forgot to set up a program setting correctly. Can anyone please give me some help?
Well, we can help a little more if you post full compile log. Its on the tab labeled "Compile Log", and the right mouse button brings up the copy menu.
Wayne
Please post the full log starting from the beginning, do not excerpt the errors. It would also be useful to know what version number of Dev you are using.
Wayne
The invalid argument it is talking about is nothing to do with the code. It is an argument being passed to the linker during the build. All the arguments being passed appear of the build command line which is logged in the 'Compile Log'. We can do nothing further until you post that text (in full).
This requirement is 'mentioned' in the thread titled "<-PLEASE READ BEFORE POSTING A QUESTION" which of course you read?!
Clifford.
Version number: 4.9.9.2
Log:
Compiler: Default compiler
Executing g++.exe...
g++.exe "\cerulean\students\2009\bse356\celsius to fahrenheit conv.cpp" -o "\cerulean\students\2009\bse356\celsius to fahrenheit conv.exe" -I"C:\c\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\c\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\c\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\c\Dev-Cpp\include\c++\3.4.2" -I"C:\c\Dev-Cpp\include" -L"C:\c\Dev-Cpp\lib"
C:\c\Dev-Cpp\Bin..\lib\gcc\mingw32\3.4.2........\mingw32\bin\ld.exe: cannot open output file \cerulean\students\2009\bse356\celsius to fahrenheit conv.exe: Invalid argument
collect2: ld returned 1 exit status
Execution terminated
Oh... it looks as if I can't write the .exe because my stupid school doesn't allow applications in personal user files...
If this is wrong, please let me know lol
Okay I moved the .cpp file to a writeable folder and it works fine. Coming off of Visual Basic programming, it's hard.
Thanks for the help!
An important warning!
Spaces in file names are a BAD idea. It will bite you eventually, and hard.
Wayne
Do you mean no spaces in the directory name or the .cpp itself?
BOTH.
Wayne
Sorry for being such an annoying noob...
My code is:
// test string program
include <cstdio>
include <cstdlib>
include <iostream>
using namespace std;
int main(int nnumberofargs, char* pszargs[])
{
// display instructions & ask for name
string name;
cout << "Welcome to the Name-a-nezator 2000!/n Please enter your name: ";
cin >> name;
}
switch(verify)
{
case True:
cout << name
cout << " will die in seven days..../n/n Thanks for using the Name-a-nezator 2000!" << endl;
system("pause");
return 0;
case False:
cout << "Please enter your REAL name!";
continue;
default:
cout << "Please enter a True or False value next time!"
continue;
}
My log is:
Compiler: Default compiler
Executing g++.exe...
g++.exe "E:\cpp-saves\namethingy.cpp" -o "E:\cpp-saves\namethingy.exe" -I"E:\Dev-Cpp\include\c++" -I"E:\Dev-Cpp\include\c++\mingw32" -I"E:\Dev-Cpp\include\c++\backward" -I"E:\Dev-Cpp\include" -L"E:\Dev-Cpp\lib"
E:/cpp-saves/namethingy.cpp:21: parse error before `switch'
E:/cpp-saves/namethingy.cpp:26: ISO C++ forbids declaration of
system' with no type E:/cpp-saves/namethingy.cpp:26:
int system' redeclared as different kind ofsymbol
E:/Dev-Cpp/include/stdlib.h:373: previous declaration of
int system(const char*)' E:/cpp-saves/namethingy.cpp:26: invalid conversion from
const char*' toint' E:/cpp-saves/namethingy.cpp:27: parse error before
return'Execution terminated
I've looked through and there seems to be no problems.... What's wrong
If at any time you wish me to just shut the hell up, please say so...
Are you the original poster on this thread?
You log shows a much different setup than the previous log. What version of Dev are you using?
Wayne
Yes, original poster.
This is version 4.9.8.0.
That is not the version you reported in an earlier post. Please be clear about your Basic 3 with each question. Features vary with version.
Now, with that quite old version of Dev, you may need to add
include<stdlib.h>
I am guessing a bit, that version is a couple of years old at least.
Is this a different computer than you were using earlier? I hope you didn't install it instead of 4.9.9.2
Wayne
Note you also have a LOT of other errors in your code. Missing ; problems with case sensitivity (True does not equal true), misuse of continue...
Wayne
Yeah, it's a different computer, but I'm running it off my portable hard drive and all these school computers have the same crap anyway.
Maybe a bit of background knowledge would help here. I'm learning C++ from (here it comes)
C++ for Dummies. I decided to switch back to the old version of Dev-C++ because it's the one they include with the book. According to the book, the Include files for this version of dev-c++ don't end in .h (only very old-fashioned programmers use .h according to them, lol)
But anyway I did try the
include<stdlib.h>
command and I get the same errors, parse error before 'switch' and such.
My goal is to make a crappy 2D RPG by the end of the year (using directx... which I have no idea how to reference yet...) and I really could use some help with basics.
Thanks so much for putting up with my problems!
There is nothing wrong with either <cstdlib> or <stdlib.h>. You need to read the error messages from the top. The first message:
E:/cpp-saves/namethingy.cpp:21: parse error before `switch'
Indicates that the compiler no longer regards the code as valid at that point. Just before that line you have a closing brace( } ), that terminated teh main() function. All the rest of the code is then outside of any function, and in that context makes no sense.
Always address the first reported error first, then consider if the others are 'cascaded' from the first, or separate issues. If in doubt, just re-compile.
You really should use 4.9.9.2, that is what most of the people that can help you here are using, so it helps if they need to reproduce your error.
Clifford
I'm on the IRC support channel at #bloodshed that no one uses according to the title... Can someone join up there and talk me through some of the basic syntax and errors?
Are we talking about the same code you posted above? You should probably start more than one thread, you seem to have started several different subjects in one thread.
Please also sign your threads with a distinct moniker (or create a Sourceforge login); it is not always clear that we are talking to the same person - especially as you keep changing the subject!
The benefit of having problems discussed in this forum is that it benefts the whole community, and the information remains available for reference. IRC is more transient, and benefits very few. This is the place to get your problems solved.
If you are talking about the code posted earlier, then it does have mre problems that the stray brace I mentioned. Reading and understanding teh error messages is a skill you need to learn, they are your first source of help. If you are havig problems understanding them, post the log. If you provide god quality information - such as what version you are using today ;) , the compile log and commented code - then you will generally get a fast response from here.
With respect yo your earlier code, after removing the stray brace:
The only values a bool type can take are true (non-zero), or false (zero). Values True and False (capitalised) are not defined - C++ is case sensitive).
If you ask the user to type True or False and assign the response to a bool, what do you expect t happen? The only response that I'd like to guarantee the result for are numeric values - zero for false, or non-zero for true. If the user types non-numeric text, I am not sure what will happen, probably always fales, always true, or undefined.
bool is a numeric type, not a string type. If you want to accept a text response, you need to use a string class object. You can't then use switch, that is only valid for integer types. If it works for bool, that is probably only because of an implicit cast to int.
Switching on a bool type!? What's the point? It only has two possible states, the default case is unreachable if you have a true and false case. A simple if-else construct will deal with a boolean value.
Clifford
Thanks!
I'll take the advice and start a new thread for basic help issues.
--original poster