LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

error: conflicting types for 'myFunctionOne'

Solved!
Go to solution

Hello,

 

The LabWindows/CVI 2013 help page for C Language Extensions appears to show function overloading being supported in the C99 extensions:

 

 "Function Overloading in C | Yes"

 

The table in the following link shows the same thing:

http://digital.ni.com/public.nsf/allkb/73AEAD30C8AF681A86257BBB0054A26B

 

I tried compiling a source file with the following overloaded function definitions with C99 extensions enabled in the Build Options:

 

 void myFunctionOne(double d) {
  printf ("Value = %f\n", d);
 }

 void myFunctionOne(int d) {
  printf ("Value = %d\n", d);
 }

 

and I get the error:

 "conflicting types for 'myFunctionOne'

 

Is function overloading truly supported, and if so, how does one enable it?

Thanks,
Mark B.

0 Kudos
Message 1 of 6
(7,153 Views)

Oh, I was a bit too quick, Constantin has the better answer Smiley Happy

0 Kudos
Message 2 of 6
(7,137 Views)
Solution
Accepted by topic author MarkB_CTC

Hello Mark,

 

You have to add __attribute__((overloadable)) at the definitions of the functions you want to overload.

void __attribute__((overloadable)) myFunctionOne(double d) {
  printf ("Value = %f\n", d);
}

void __attribute__((overloadable)) myFunctionOne(int d) {
  printf ("Value = %d\n", d);
}

You can see an examples of clang extensions here.

 

Constantin

Message 3 of 6
(7,135 Views)
Solution
Accepted by topic author MarkB_CTC

Thanks, Constantin.  Works perfectly.  Looks like there's a whole world of attributes out there - I see a research project in my future.

 

Wolfgang, thanks for taking the time to reply, also.

 

Best regards,

Mark B.

0 Kudos
Message 4 of 6
(7,104 Views)

I think you can also use the 'weak' attribute and/or pragma, although I haven't tried.

0 Kudos
Message 5 of 6
(7,065 Views)

@gdargaud wrote:

I think you can also use the 'weak' attribute and/or pragma, although I haven't tried.


Thanks, I'll look into it.

Mark

0 Kudos
Message 6 of 6
(7,061 Views)