Andrew.M
Andrew.M

Reputation: 110

Why error: Redefinition; previous definition of y0 was ‘function’?

The only thing written in the code are:

#include <iostream>
using namespace std;


int x0, y0;

And it’s giving me an error when I compile: ‘y0’: redefinition; previous definition was ‘function’

Upvotes: 1

Views: 4332

Answers (1)

catnip
catnip

Reputation: 25388

It seems that y0 is a built-in function in gcc (and maybe some other compilers), see:

https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html

And then scan through for:

Outside strict ISO C mode (-ansi, -std=c90, -std=c99 or -std=c11), the functions ... y0 ... may be handled as built-in functions...

So, tl;dr, use a different name.

You can see the helpful error message that gcc generates here, although, in gcc 8.1 at least, this is only a warning:

prog.cc:4:9: warning: built-in function 'y0' declared as non-function [-Wbuiltin-declaration-mismatch] int x0, y0;

So, for next time OP, so that you won't get voted down (although I didn't - this time), please:

  • include the full text of the error message in your question (I mean really, why not?)
  • tell us which compiler you are using (make and version)

Thanks.

Upvotes: 8

Related Questions