Warning: "x" redefined

I have this code and when I try to verify/upload it it just sends me these warnings but still uploads the code:

In file included from C:\Users\Matte\Desktop\GBCartRead-master\GBCartRead_v1_8_Rev1_Arduino\GBCartRead_v1_8_Rev1_Arduino.ino:25:0:

sketch\pindeclarations.h:13:0: warning: "PB0" redefined

 #define PB0 0

 ^

In file included from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:627:0,

                 from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28,

                 from sketch\GBCartRead_v1_8_Rev1_Arduino.ino.cpp:1:

c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\portpins.h:124:0: note: this is the location of the previous definition

 #  define PB0 PORTB0

 ^

In file included from C:\Users\Matte\Desktop\GBCartRead-master\GBCartRead_v1_8_Rev1_Arduino\GBCartRead_v1_8_Rev1_Arduino.ino:25:0:

sketch\pindeclarations.h:14:0: warning: "PB1" redefined

 #define PB1 1

 ^

In file included from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:627:0,

                 from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28,

                 from sketch\GBCartRead_v1_8_Rev1_Arduino.ino.cpp:1:

c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\portpins.h:129:0: note: this is the location of the previous definition

 #  define PB1 PORTB1

 ^

In file included from C:\Users\Matte\Desktop\GBCartRead-master\GBCartRead_v1_8_Rev1_Arduino\GBCartRead_v1_8_Rev1_Arduino.ino:25:0:

sketch\pindeclarations.h:15:0: warning: "PB2" redefined

 #define PB2 2

 ^

In file included from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:627:0,

                 from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28,

                 from sketch\GBCartRead_v1_8_Rev1_Arduino.ino.cpp:1:

c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\portpins.h:134:0: note: this is the location of the previous definition

 #  define PB2 PORTB2

 ^

In file included from C:\Users\Matte\Desktop\GBCartRead-master\GBCartRead_v1_8_Rev1_Arduino\GBCartRead_v1_8_Rev1_Arduino.ino:25:0:

sketch\pindeclarations.h:16:0: warning: "PB3" redefined

 #define PB3 3

 ^

In file included from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:627:0,

                 from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28,

                 from sketch\GBCartRead_v1_8_Rev1_Arduino.ino.cpp:1:

c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\portpins.h:139:0: note: this is the location of the previous definition

 #  define PB3 PORTB3

 ^

In file included from C:\Users\Matte\Desktop\GBCartRead-master\GBCartRead_v1_8_Rev1_Arduino\GBCartRead_v1_8_Rev1_Arduino.ino:25:0:

sketch\pindeclarations.h:17:0: warning: "PB4" redefined

 #define PB4 4

 ^

In file included from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:627:0,

                 from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28,

                 from sketch\GBCartRead_v1_8_Rev1_Arduino.ino.cpp:1:

c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\portpins.h:144:0: note: this is the location of the previous definition

 #  define PB4 PORTB4

 ^

In file included from C:\Users\Matte\Desktop\GBCartRead-master\GBCartRead_v1_8_Rev1_Arduino\GBCartRead_v1_8_Rev1_Arduino.ino:25:0:

sketch\pindeclarations.h:18:0: warning: "PB5" redefined

 #define PB5 5

 ^


...goes on like this until



In file included from C:\Users\Matte\Desktop\GBCartRead-master\GBCartRead_v1_8_Rev1_Arduino\GBCartRead_v1_8_Rev1_Arduino.ino:25:0:

sketch\pindeclarations.h:36:0: warning: "PD5" redefined

 #define PD5 5

 ^

In file included from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:627:0,

                 from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28,

                 from sketch\GBCartRead_v1_8_Rev1_Arduino.ino.cpp:1:

c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\portpins.h:235:0: note: this is the location of the previous definition

 #  define PD5 PORTD5

 ^

In file included from C:\Users\Matte\Desktop\GBCartRead-master\GBCartRead_v1_8_Rev1_Arduino\GBCartRead_v1_8_Rev1_Arduino.ino:25:0:

sketch\pindeclarations.h:37:0: warning: "PD6" redefined

 #define PD6 6

 ^

In file included from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:627:0,

                 from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28,

                 from sketch\GBCartRead_v1_8_Rev1_Arduino.ino.cpp:1:

c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\portpins.h:240:0: note: this is the location of the previous definition

 #  define PD6 PORTD6

 ^

In file included from C:\Users\Matte\Desktop\GBCartRead-master\GBCartRead_v1_8_Rev1_Arduino\GBCartRead_v1_8_Rev1_Arduino.ino:25:0:

sketch\pindeclarations.h:38:0: warning: "PD7" redefined

 #define PD7 7

 ^

In file included from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:627:0,

                 from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28,

                 from sketch\GBCartRead_v1_8_Rev1_Arduino.ino.cpp:1:

c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\portpins.h:245:0: note: this is the location of the previous definition

 #  define PD7 PORTD7

 ^

Sketch uses 3962 bytes (12%) of program storage space. Maximum is 32256 bytes.
Global variables use 297 bytes (14%) of dynamic memory, leaving 1751 bytes for local variables. Maximum is 2048 bytes.

I'd like to add that in my code I don't use "io.h", "pgmspace.h", "Arduino.h" or "portpins.h".
I only use a help file i created: "pindelcarations.h".

Do I have to ignore these warnings since I don't use any of those .h files mentioned in the warnings? Or do I have to fix something?

Thanks in advance.

You are using the Arduino IDE, so you are using Arduino.h whether you know it or not. Arduino.h drags in other things like io.h, pgmspace.h and portpins.h

This is a warning, so you could ignore it I suppose but you may not get the results that you intend. It would be better if you would change your pindeclarations.h to use something that is not already defined instead of PB0, perhaps MattePB0.

Of course, then you will have to change PB0 wherever you used it as well.

Well, he's defining them as the same value they were previously defined as, in this case....

Why is his sketch doing that? I would venture a guess that earlier versions of Arduino weren't pulling in portpins.h.

vaj4088:
You are using the Arduino IDE, so you are using Arduino.h whether you know it or not. Arduino.h drags in other things like io.h, pgmspace.h and portpins.h

This is a warning, so you could ignore it I suppose but you may not get the results that you intend. It would be better if you would change your pindeclarations.h to use something that is not already defined instead of PB0, perhaps MattePB0.

Of course, then you will have to change PB0 wherever you used it as well.

So if I just change "PB0",etc in something else should the code work?

This is how my pindeclarations.h is coded:

#ifndef PIN_DECLARATIONS_H_ 
#define PIN_DECLARATIONS_H_ 
 
 
#define PA0 0 
#define PA1 1 
#define PA2 2 
#define PA3 3 
#define PA4 4 
#define PA5 5 
#define PA6 6 
#define PA7 7 

 
#define PB0 0 
#define PB1 1 
#define PB2 2 
#define PB3 3 
#define PB4 4 
#define PB5 5 
#define PB6 6 
#define PB7 7 

 
#define PC0 0 
#define PC1 1 
#define PC2 2 
#define PC3 3 
#define PC4 4 
#define PC5 5 
#define PC6 6 
#define PC7 7 

 
#define PD0 0 
#define PD1 1 
#define PD2 2 
#define PD3 3 
#define PD4 4 
#define PD5 5 
#define PD6 6 
#define PD7 7 

 
#define wrPin_high    PORTC |= (1<<PC3); 
#define wrPin_low     PORTC &= ~(1<<PC3); 
#define mreqPin_high  PORTC |= (1<<PC4); 
#define mreqPin_low   PORTC &= ~(1<<PC4); 
#define rdPin_high    PORTC |= (1<<PC5); 
#define rdPin_low     PORTC &= ~(1<<PC5); 
#define latchPin_high PORTB |= (1<<PB2); 
#define latchPin_low  PORTB &= ~(1<<PB2);
#define dataPin_high  PORTB |= (1<<PB3); 
#define dataPin_low   PORTB &= ~(1<<PB3); 
#define clockPin_high PORTB |= (1<<PB5); 
#define clockPin_low  PORTB &= ~(1<<PB5); 

 
#endif /* PIN_DECLARATIONS_H_ */

How can I rewrite this to not interfere with portpins.h? Should I just change name of "PB0", "PB1", etc?

#ifndef PA0
#define PA0 0
#define PA1 1
...
#endif

#ifndef PB0
#define PB0 0
#define PB1 1
...
#endif
...

<< EDIT >>

Hmm... may need some adjustment: ATmega32u4 has PC6 and PC7, but no PC0.

Should I just change name of "PB0", "PB1", etc?

Yes. Use names that do not conflict with the Arduino-defined names.

oqibidipo:

#ifndef PA0

#define PA0 0
#define PA1 1
...
#endif

#ifndef PB0
#define PB0 0
#define PB1 1
...
#endif
...





<< EDIT >>

Hmm... may need some adjustment: ATmega32u4 has PC6 and PC7, but no PC0.

What does this mean? Why should I code it in that precise way?

Actually, if you don't care about possible compatibility with older IDE versions, the easiest way is to just throw them away.

The code is from GitHub - insidegadgets/GBCartRead: Read ROM, Read RAM or Write RAM from/to a Gameboy Cartridge. (License CC-BY), I presume.

oqibidipo:
The code is from GitHub - insidegadgets/GBCartRead: Read ROM, Read RAM or Write RAM from/to a Gameboy Cartridge. (License CC-BY), I presume.

Yes it is!
The owner of the code just told me to throw all the first part of pindeclarations.h away, just like you told me.
If I do so, would the code run properly anyway?
Do I have to change something else in the .ino code?

Geration111:
If I do so, would the code run properly anyway?

Yes, the definitions come from avr/io.h and/or avr/portpins.h.

Do I have to change something else in the .ino code?

No, unless you want to use a different board.

oqibidipo:
Yes, the definitions come from avr/io.h and/or avr/portpins.h.
No, unless you want to use a different board.

I am using an Arduino UNO, the code should work for Arduino Duemilanove and Arduino UNO.