• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

C++ Quick understanding of Compiler Errors & Warnings in C++


Staff Team
Company Plus
Hey everyone, so I've been learning C++ these last couple weeks and I thought perhaps I could share what I had learned to help you out. I believe that one of the best things to do to help you learn is to teach others, so here I am! I'll keep this brief and simple, I'll also include the URL to the course on Udemy!

First things first, what is a compiler?

A compiler is used to translate your code into something your machine can understand. It inputs the source code (the code that the programmer writes) and converts it into object code (what computers understand e.g. 1110110101).

Compiler Errors

There are two types of errors; Syntax Errors and Semantic Errors. Both provide a pretty good example of what's going on with your code. These errors occur when the code you are writing is conflicting with the set of rules of a programming language.

Syntax Errors:
A syntax error occurs when there is something wrong with the structure of the code, e.g.​
[CODE lang="cpp" title="Example Syntax Error" highlight="2"]//Cout is misspelt
std::cot << "Hello World" << std::endl;
return 0;


Semantic Errors
A semantic error occurs when there is something wrong calculation or logic, e.g.​
[CODE lang="cpp" title="Example Semantic Error" highlight="3"]// You can not divide "Hello" because it's a string and not an integer

std::cout << ("Hello"/10);[/CODE]
Compiler Warnings

A compiler warning is the compiler recognized an issue with a piece of your code that could possibly lead to a problem later on. It is very important to not ignore them but to consider them as errors. This could mean that you could be running a piece of code that you have an unused variable or a variable with no assigned value.​
[CODE lang="cpp" title="Compiler Warning"]int age;
std::cout << age;[/CODE]

Want to learn C++ too? Check out the course! URL: https://www.udemy.com/beginning-c-plus-plus-programming/
Last edited:
Top Bottom