expected identifier before the name of the function on first line

272 views Asked by At

I have a code:

void switch (int *a, int *b) 
{
    int temp = *a;
    *a = *b;
    *b = temp;
}

It's the function I include in other .c file by this one .h file:

#ifndef SWITCHINT_H
#define SWITCHINT_H

void switch (int *a, int *b);

#endif

But console prints that:

switchInt.c:1:5: error: expected identifier or ‘(’ before ‘switch’
 void switch (int *a, int *b);s
switchInt.h:4:6: error: expected identifier or ‘(’ before ‘switch’
 void switch (int *a, int *b);

What should i do?

1

There are 1 answers

0
hououin kyouma On BEST ANSWER

The error occurred due to a reserved name of the function ("switch")

Thanks Fiddling Bits for help!

P.S: I'm sorry for being so blind :(