Troubleshooting Compilation Errors: Why Won't My Program Compile?

Click For Summary

Discussion Overview

The discussion revolves around troubleshooting compilation errors in a programming context, specifically related to a user's code that fails to compile. Participants provide suggestions and insights on how to identify and resolve these errors, focusing on code formatting, compiler messages, and common pitfalls in programming.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Homework-related

Main Points Raised

  • One participant suggests that the user should paste their code directly into the forum instead of linking to an image, recommending the use of specific formatting tags.
  • Another participant emphasizes the importance of providing specific compiler error messages and the lines they refer to for effective troubleshooting.
  • A participant compares the situation to visiting a doctor, highlighting the need for detailed information about the problem.
  • One user claims their own compilation of the code worked fine and provides a specific command for compiling on Ubuntu.
  • Another participant points out that the first three lines of the user's code may not be recognized as comments, suggesting a change in syntax to correct this issue.
  • One participant notes that the user might have written their code in an inappropriate buffer and recommends removing certain lines before compiling.
  • A new programmer mentions their habit of including specific headers and using a namespace in all their programs, although this may not directly address the user's issue.
  • A later reply corrects the previous suggestion about using namespaces, clarifying that the user is writing in C rather than C++, and advises only importing necessary components.

Areas of Agreement / Disagreement

Participants express various suggestions and observations, but there is no consensus on the specific cause of the compilation errors or a definitive solution. Multiple competing views and approaches are presented.

Contextual Notes

Some participants' suggestions depend on assumptions about the user's coding environment and practices, which may not be fully articulated. There are also unresolved aspects regarding the specific nature of the compilation errors encountered.

mkbh_10
Messages
217
Reaction score
0
Tell me why am i not able to compile this program, the terminal lists various errors

http://tinypic.com/r/1zxtm5h/7
 
Technology news on Phys.org
Two tips:

1. It's a lot faster for other people here if you paste your code directly into your posting instead of making us wait for a large picture to download. To keep the code formatted properly, enclose it in [ CODE ] and [ /CODE ] tags (remove the spaces that I added between the brackets).

2. It helps a lot if you tell us what compiler error messages you got, and what line they refer to.
 
I am new to programming , i will do wat u said ...
 
Think of it this way: when you go to the doctor, you don't just tell him, "I hurt." You tell him where you hurt and what kind of pain it is. :smile:
 
Worked fine for me.
What did you type to compile?

Looks like you are in Ubuntu, so try:
g++ sinx3.cpp -o runMe
 
I may be off here, but it appears that those first three lines are supposed to be comments but aren't being treated as such. If you notice the words 'buffer' 'is' and 'for' are all syntax highlighted. Also the text between the single quotes in don't and file's is highlighted as if it were a string constant.

I recommend changing those double semicolons to double slashes like the rest of the comments.
 
Yeah it seems you have written it in the Emacs *scratch* buffer and then saved it to file, remove the first 3 lines. Then try to compile with the command already written here.
 
i don't know if this will help your problem at all but I am also new to c++ and i have just gotten in the habit of including: "#include <cstdlib>" ; and "using namespace std". in all of my programs
 
@ Bad
He's writing in C, not C++
But aside from that, namespace std - in the future you should consider only import those that actually needed.
But at the moment it's okay.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
14
Views
4K
Replies
4
Views
5K
  • · Replies 32 ·
2
Replies
32
Views
4K
  • · Replies 17 ·
Replies
17
Views
3K
Replies
59
Views
9K
  • · Replies 70 ·
3
Replies
70
Views
5K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K