Sachin
Sachin

Reputation: 21931

Calling a C function in a pro*C file

I have these line in my pro*C program. The function initAverage(int i) is defined in a C language and I am trying to call this function in a .pcc (Pro C++) file.

I am getting an error

Error: initAverage(int i);was declared before with a different language

extern "C"
{
int initAverage(int i);
}

Upvotes: 0

Views: 854

Answers (1)

jdehaan
jdehaan

Reputation: 19938

You probably have an include before that already declares initAverage without extern "C". Look at all declarations of initAverage and fix the missing extern declaration then it should be fine.

PS: Adding the calling convention explicitly is a good idea in general. I would add that too (while not being actually part of the question)

Upvotes: 2

Related Questions