…/Core/Src/main.c(113): error: #29: expected an expression
preface
When defining a macro, you habitually align and type spaces, resulting in an error when calling
1. Wrong situation
#define SDA_High() do{HAL_GPIO_WritePin(I2C_Port,I2C_SDA_Pin,GPIO_PIN_SET);}while(0)
#define SDA_Low () do{HAL_GPIO_WritePin(I2C_Port,I2C_SDA_Pin,GPIO_PIN_RESET);}while(0)
// SDA_Low () Spaces added for alignment
When calling the program
SDA_Low();
SDA_High();
Program error:
…/core/SRC/main. C (113): error: #29: expected an expression
…/core/SRC/main. C (113): error: #65: expected a “;”
solution: remove the space
Summary
Format #define identifier replacement list of macro definition
macro definition uses “identifier” to represent the content in the “replacement list”. The identifier is called the macro name. During preprocessing, the preprocessor will replace all macro names in the source program with the contents in the replacement list in the macro definition. When defining many parameters, it is recommended to use do {} while (0). For reasons, refer to the benefits of using do {} while (0) in macro definition
Read More:
- How to Solve Keil Error: error: #29: expected an expression
- Vue+TS main.ts error: unused expression, expected an assignment or function call
- [Solved] KEIL Error: keil Error: failed to execute ‘C:\Keil\ARM\ARMCC‘
- [Solved] Keil C Error: error C141: syntax error near ‘=‘, expected ‘__asm‘
- Keil Error: error:#130:expected a “{” [How to Solve]
- [Solved] Keil-MDK Error: “Error: Encountered an improper argument”
- error: expected ‘;‘ at end of member declaration and expected ‘)‘ before ‘&‘ toke Errors
- keil error #1-D: last line of file ends without a newline
- How to Solve UW Microcontroller KEIL _WEAK Error
- [Solved] Keil error: #101: “name“ has already been declared in the current scope
- keil: ERROR L107:ADDRESS SPACE OVERFlOW [How to Solve]
- (Keil MDK) UCOS floating point support abnormal solution
- Keil’s duplicate definition problem: Error: L6200E: Symbol F6x8 multiply defined
- [Solved] Unity Error: Assertion failed on expression: ‘IsMatrixValid(matrix)‘…
- [Solved] keil arm_math Error: error: #35: #error directive: “Define according the used Cortex cor
- Error:invalid new-expression of abstract class type XXX [How to Solve]
- [Solved] conda activates the virtual environment error: Invoke-Expression
- How to Solve Error Swift 4 Expression type ‘@value CGRect’ is ambiguous without more context
- [Solved] Keil Error: Error: Flash Download failed – “Cortex-M4“
- [Solved] SyntaxError: Invalid regular expression: invalid group specifier name