简体   繁体   中英

expected identifier before the name of the function on first line

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?

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

Thanks Fiddling Bits for help!

PS: I'm sorry for being so blind :(

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM