LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-01-2004, 06:25 AM   #1
noir911
Member
 
Registered: Apr 2004
Posts: 682

Rep: Reputation: Disabled
[C++] -Wall Output


I have written a very simple C++ program [1] and used "g++ -Wall -pedantic -o kay kay.cpp" to compile it.

The -Wall and -pedantic gives me a bunch of library errors which all looks Hebrew to me. I was wondering what man page or document to read to decipher the meaning.

Thanks for any kind of help.


[1] 1 #include <iostream>
2
3 using namespace std;
4
5 int main (void) {
6
7 int answer, product;
8 product = 123*456;
9 while(1) {
10 cout << "Enter number" <<endl;
11 cin >> answer;
12 if (answer == product)
13 break;
14 cout << "wrong"<<endl;
15 }
16 cout << "well done"<<endl;
17 }
 
Old 08-01-2004, 06:55 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Hmm, I copy-pasted your code. Then I removed the line-numbers, and compiled-linked it with your command: "g++ -Wall -pedantic -o kay kay.cpp".

Not a single warning, nor any error! Though I expected at least one for a missing "return 0;" at the end of main().
Or did you actually have the line numbers included? If so, C(++) sources, should not contain line numbers. Or you should comment them of course...

Try this (cleaned up) version of your code:
Code:
#include <iostream>

using namespace std;

int main (void) {

	int answer, product;
	product = 123*456;
	while(1) {
		cout << "Enter number" <<endl;
		cin >> answer;
		if (answer == product)
			break;
		cout << "wrong"<<endl;
	}
	cout << "well done"<<endl;
	return 0;
}

Last edited by Hko; 08-01-2004 at 06:59 AM.
 
Old 08-01-2004, 08:17 AM   #3
noir911
Member
 
Registered: Apr 2004
Posts: 682

Original Poster
Rep: Reputation: Disabled
Thanks for your quick reply. The line-numbers were given intentionally using cat and I never compiled w/ line-numbers. I compiled again & everything came out clean.

Anyhow, sometimes we have errors when we compile w/ -Wall and -pedantic - errors which are not visible in normal -o compilations. Myquestions is how to know more about those errors. Most of the time they are link library related errors. How can we decipher the meaning of those errors? gdb? ddd? or anything else?

Regards,
Noir.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
fire wall berrance Red Hat 2 08-21-2004 12:55 PM
Do I need a fire wall? shanenin Linux - Security 9 12-11-2003 02:21 AM
how do i get through a fire wall pureskater561 Linux - Security 2 11-04-2003 10:48 AM
A guified wall? WeNdeL Linux - Software 0 10-10-2003 12:14 PM
Smooth Wall Hoops66 Linux - Security 12 09-12-2003 02:47 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration