tags:

views:

52

answers:

1

I have these line in my pro*C program. The function initAerage 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);
}

Please help

+1  A: 

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)

jdehaan
Please have a look at the error statement initAverage(int i);was declared before with a different language.It says the function is declared but in a different language
Sachin Chourasiya
if `extern "C"` is missing it is NOT C anymore but the default language (C++/Pro C++?) so add `extern "C"` everywhere in the definition and declaration.
jdehaan