latheturner
latheturner

Reputation: 11

Implicit declaration of function, expected ‘;’, ‘,’ or ‘)’

Compiler is giving errors as shown below. As far as I can tell the constants are declared correctly as well as my function calls. The program calculates a triangles area and perimeter and uses 5 different functions. Any help would be appreciated.

 program05.c:16:22: error: expected ‘;’, ‘,’ or ‘)’ before 'A'
 #define SIDE_1_LABEL 'A'
                      ^
program05.c:20:25: note: in expansion of macro ‘SIDE_1_LABEL’
 float getUserValue(char SIDE_1_LABEL, char SIDE_2_LABEL);
                         ^
program05.c: In function ‘main’:

…
#include <stdio.h>
#include <math.h>

#define SIDE_1_LABEL 'A'
#define SIDE_2_LABEL 'B'

void printInstructions();
float getUserValue(char SIDE_1_LABEL, char SIDE_2_LABEL);
float calculateArea(float side1, float side2);
float calculatePerimeter(float side1, float side2);
void printResults(float side1, float side2, float area, float perimeter);

int main()
{
    …

Upvotes: 0

Views: 105

Answers (1)

You wrote:

#define SIDE_1_LABEL 'A'
#define SIDE_2_LABEL 'B'

float getUserValue(char SIDE_1_LABEL, char SIDE_2_LABEL);

That is exactly the same as writing:

float getUserValue(char 'A', char 'B');

which is obviously invalid because 'A' and 'B' are not variable names.

If you weren't aware - macro expansion works as if you literally copy-pasted the macro definition everywhere the macro appears.

Upvotes: 3

Related Questions