Vicky
Vicky

Reputation: 1235

Syntax error in inline functions in C language

I am trying below simple example by using inline functions in C language. Its giving me a compilation error(on inline function) as shown below.

  Error test.c 1: Declaration Syntax Error

My C code is as shown below

inline int square(int a)
{
    return(a*a);
}
void main()
{
    int no,result;
    clrscr();
    printf("\nEnter the number ");
    scanf("%d",&no);
    result=square(no);
    printf("\n Square is %d ",result);
    getch();

 }

Upvotes: 0

Views: 284

Answers (1)

Dai
Dai

Reputation: 155708

I am using Turbo C++ 3.2

There's your problem:

Solution:

  • Use a C compiler released in the past 20 years that supports C99.
    • C++ compilers are not C compilers, btw.
      • While C++ inherits most of C, which means most C++ compilers support a good subset of C, they do not need to support all of C99, C11, C18, C2x, etc.

Upvotes: 4

Related Questions