Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

XC8 warning - what is wrong?

Pommie

Well-Known Member
Most Helpful Member
I've got a project and I have many warnings along the line of,
main.c:219:: warning: (1518) direct function call made with an incomplete prototype (I2cStop)
At line 219 of main I have,
1705378046267.png

In i2c.c I have,
1705377740228.png

And in i2c.h I have,
1705377839817.png

In main, before this warning I have various other calls to the i2c routines that don't cause any warning whatsoever.
Anyone any idea what's causing this?

I know it's only a warning but there are so many of them I can't see any "real" warnings and will probably miss them.

Thanks,

Mike.
As I'm typing this I worked it out, I need void inside the empty brackets of the prototypes. Has this been recently introduced? I'm sure I used this exact same code many years ago without any warnings.
 
Using void in a function with no parameters is correct. I have always defined them so I never get a warning.
If you are using C99 it may be more strict than previous iterations.

Most of the time my function prototypes and function definitions will have the "parameters" set to void.
 
(1518) * function call made with an incomplete prototype (*) (Code Generator)

A function has been called with the compiler not having seen a complete prototype for that function. Check for an empty parameter list in the declaration.

The 'void I2cStop();' is a declaration but not a prototype, while 'void I2cStop(void);' is a declaration and a prototype. Without the parameters specified, it's an old, obsolete form of a declaration.

It's not recent (dating back to 1989 or so), but maybe reporting it as an error is.
 
void I2cStop(void);
This is news to me :facepalm: Please explain , should a prototype function and the declaration with no parameters always have (void ) the as in void I2cStop(void); Any downside with void I2cStop(); in both I must have acres of code with no (void) seems to work fine, XC8 v2.45 . Is this MCC code ?

Just replaced all the void xxxxxxx() and (): with (void) in a small project XC8
errors.jpg

19 errors "error expected an expression"
Had to revert from yesterdays file no (void) , now more errors "undefined symbol " :banghead: :banghead::banghead:

OH dear .. XC8 didn't like the first __delay_ms(200) ,so comment it out ... no error , put it back in no error MPLABX is wonderful ...
 
Last edited:
This is news to me :facepalm: Please explain , should a prototype function and the declaration with no parameters always have (void ) the as in void I2cStop(void); Any downside with void I2cStop(); in both I must have acres of code with no (void) seems to work fine, XC8 v2.45 . Is this MCC code ?
As I understand it, both the function itself, and the prototype for it, must have (void) at the end. Actually calling the routine only needs (), no need for (void).
 
Nothing to do with MCC.
The "no void" form is an old, now obsolete form from before function prototypes existed (old K&R). I think it was C11 that introduced it.

It basically means "any parameters". I don't think it'll cause problems in most cases, but you should really include the (void) if that's what you mean.
 
Has anyone checked if you suppress that warning, as the warning is only to keep the programmer informed that they CANNOT pass parameters to it.

You only need to specify the void in the prototype, but as I copy the function name to the header "as is" its easier for me to write it at the declaration time.. Horses for courses.
 
You can suppress the warning by adding '#pragma warning disable 1518' to your .c file.
Then it won't complain if you use 'void I2cStop();'

This is assuming you're using XC8 v2.45 in C99 mode (which is the default).
If you use older v1.xx versions or C90 mode I don't think you'll even see the warning.
 

Latest threads

New Articles From Microcontroller Tips

Back
Top