Active3 years, 4 months ago
I got the error
When I change
Error[Pe018]: expected a ')'
at CPU_state cpuStateOff
.When I change
cpuStateOff
to 0
it's OK. I don't know why.Intuitive to Use. Easy to manage. 200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.
In my
PERIPHERAL_APP.h
:In my
red0ctmain.c
: 2,06433 gold badges1010 silver badges2424 bronze badges
user3778432user3778432
1 Answer
Preprocessor macros are not C statements, and therefore doesn't need a statement terminator like
;
.What happens is that when the preprocessor replaces the macro
cpuStateOff
it uses the whole body of the macro, i.e. 0;
which results in code likeMost compilers and environments have options to stop after preprocessing, if you use it you can see exactly what code the compiler 'proper' will see.
Some programmer dudeSome programmer dude316k2626 gold badges285285 silver badges454454 bronze badges
Not the answer you're looking for? Browse other questions tagged cmsp430iar or ask your own question.
Error is an illegal operation performed by the user which results in abnormal working of the program.
Programming errors often remain undetected until the program is compiled or executed. Some of the errors inhibit the program from getting compiled or executed. Thus errors should be removed before compiling and executing.
The most common errors can be broadly classified as follows.
Programming errors often remain undetected until the program is compiled or executed. Some of the errors inhibit the program from getting compiled or executed. Thus errors should be removed before compiling and executing.
The most common errors can be broadly classified as follows.
![Expression Expression](/uploads/1/2/5/3/125316809/111699648.png)
Type of errors
- Syntax errors: Errors that occur when you violate the rules of writing C/C++ syntax are known as syntax errors. This compiler error indicates something that must be fixed before the code can be compiled. All these errors are detected by compiler and thus are known as compile-time errors.
Most frequent syntax errors are:- Missing Parenthesis (})
- Printing the value of variable without declaring it
- Missing semicolon like this:
// syntax error
void
main()
int
x = 10;
}
Error: - Syntax of a basic construct is written wrong. For example : while loop
// syntax error
int
main(
void
)
// while() cannot contain '.' as an argument.
{
}
}
Error:In the given example, the syntax of while loop is incorrect. This causes a syntax error.
- Run-time Errors : Errors which occur during program execution(run-time) after successful compilation are called run-time errors. One of the most common run-time error is division by zero also known as Division error. These types of error are hard to find as the compiler doesn’t point to the line at which the error occurs.
For more understanding run the example given below.// run-time error
void
main()
int
n = 9,
div
= 0;
// wrong logic
// so this program abnormally terminates
}
Error:In the given example, there is Division by zero error. This is an example of run-time error i.e errors occurring while running the program. - Linker Errors: These error occurs when after compilation we link the different object files with main’s object using Ctrl+F9 key(RUN). These are errors generated when the executable of the program cannot be generated. This may be due to wrong function prototyping, incorrect header files. One of the most common linker error is writing Main() instead of main().
// linker error
{
printf
(
'%d'
, a);
Error: - Logical Errors : On compilation and execution of a program, desired output is not obtained when certain input values are given. These types of errors which provide incorrect output but appears to be error free are called logical errors. These are one of the most common errors done by beginners of programming.
These errors solely depend on the logical thinking of the programmer and are easy to detect if we follow the line of execution and determine why the program takes that path of execution.// logical error
{
for
(i = 0; i < 3; i++);
printf
(
'loop '
);
}
return
0;
No output - Semantic errors : This error occurs when the statements written in the program are not meaningful to the compiler.
// semantic error
{
a + b = c;
//semantic error
Error
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.