I am new to Arduino and most programming in general. I wrote a program for a basic calculator that I plan on making. I used void functions for different parts of the code. for example, I have made a function where the code reads the value of the first number the user inputs. I keep getting the error message "/tmp/090507220/Calculator/Calculator.ino:125:3: error: expected '}' before 'if'
exit status 1" I have no clue what to do. it also displays "CalculatorVal2 not declared in this scope"(calculatorval2 is the name of a function) I am calling the function in an if statement. Can u not do that?. This is my first real project, any help would be greatly appreciated.
it also displays "CalculatorVal2 not declared in this scope"(calculatorval2 is the name of a function)
If calculatorval2 is the name of the function, the compiler would not be complaining about CalculatorVal2 not being declared in this scope. Case matters.
Post your code AND the EXACT error messages - not your incorrect paraphrasing of them.
Common compiler errors caused by mismatched brackets:
"does not name a type" or
"expected declaration before" or
"expected unqualified-id before"
Usually means you forgot a '{' or put in an extra '}' in the previous function. Since all of the open brackets have been closed, the compiler is looking for further global declarations (variables or functions). If it finds something that looks like executable code instead of a global declaration it emits an error. Make sure that the brackets in the preceding function are in matching pairs '{' followed by '}'.
"a function-definition is not allowed here before '{' token"
(can cause: "'functionName' was not declared in this scope")
Usually means you forgot a '}' or put in an extra '{' in the previous function. Since a set of brackets has not been closed yet the compiler is looking for more code to put in the function. You can't declare a function inside a function so if the compiler finds a function definition it emits an error. Make sure that the brackets in the preceding function are in matching pairs '{' followed by '}'.
"expected '}' at end of input"
Usually means you forgot a '}' or put in an extra '{' in the last function in the sketch. Since a set of brackets has not been closed yet, the compiler is looking for more code to put in the function. When it hits the end of the file instead it emits an error. Make sure that the brackets in the last function are in matching pairs '{' followed by '}'.
"expected primary-expression before '}' token"
Usually means you have an incomplete statement before a '}'. The block statement (between '{' and matching '}') can only contain complete statements.