Allegro.cc - Online Community
Post Reply

Allegro.cc Forums » Programming Questions » Mappyal.h conflicting declaration of BLKSTR and ANISTR

rss feed Print
Mappyal.h conflicting declaration of BLKSTR and ANISTR
Jakku Night
Member #17,868
June 2020
avatar

Hello, I'm looking out for this in the web but I cannot found anything about it. I compiled A project with mappyal.h and the compiler returns the next error:
||=== Build: Debug in RPG (compiler: GNU GCC Compiler) ===|
C:\Users\User\Desktop\RPG\mappyal.h|56|error: conflicting declaration 'typedef struct BLKSTR BLKSTR'|
C:\Users\User\Desktop\RPG\mappyal.h|56|note: previous declaration as 'typedef struct BLKSTR BLKSTR'|
C:\Users\User\Desktop\RPG\mappyal.h|66|error: conflicting declaration 'typedef struct ANISTR ANISTR'|
C:\Users\User\Desktop\RPG\mappyal.h|66|note: previous declaration as 'typedef struct ANISTR ANISTR'|
C:\Users\User\Desktop\RPG\main.cpp||In function 'int _mangled_main()':|
C:\Users\User\Desktop\RPG\main.cpp|46|warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]|
||=== Build failed: 2 error(s), 1 warning(s) (0 minute(s), 0 second(s)) ===|

How it is? I didn't modify the code of the file and I followed all intructions to build mappyal.h. I'm using Codeblocks under Windows 10. : :)

Here I put the header file

NOTE: I'm starting programing in C/C++ and Allegro 4.2.2 ;RE

Peter Hull
Member #1,136
March 2001

Almost certainly you have included mappyal.h twice, either directly or indirectly. See https://en.wikipedia.org/wiki/Include_guard

Second issue, on line 46 I guess you have something like:

char* text = "some text";

Just change char* to const char*

Jakku Night
Member #17,868
June 2020
avatar

Well. I'll try this and return after that

Ok. I did it but the compiler now send me this errors:

||=== Build: Debug in RPG (compiler: GNU GCC Compiler) ===|
C:\Users\User\Desktop\RPG\room.cpp|3|multiple definition of `bgoff'|
obj\Debug\main.o:C:\Users\User\Desktop\RPG\main.cpp|38|first defined here|
C:\Users\User\Desktop\RPG\room.cpp|3|multiple definition of `fgoff'|
obj\Debug\main.o:C:\Users\User\Desktop\RPG\main.cpp|38|first defined here|
C:\Users\User\Desktop\RPG\room.cpp|3|multiple definition of `fgoff2'|
obj\Debug\main.o:C:\Users\User\Desktop\RPG\main.cpp|38|first defined here|
C:\Users\User\Desktop\RPG\room.cpp|7|multiple definition of `fgoff3'|
obj\Debug\main.o:C:\Users\User\Desktop\RPG\main.cpp|38|first defined here|
||error: ld returned 1 exit status|
||=== Build failed: 9 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

What is this error? I don't know why.

I followed the instructions to build the .o file and link it to my project (It is explained in the README.txt of Mappy) Should I rebuild it? What steps should I follow to link the mappyal under Codeblocks in Windows?

Thanks for the responses :RE

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

It looks like you're linking more than once.

Either add mappyal.c to your project, or link it once at the end.

DanielH
Member #934
January 2001
avatar

Your main.cpp file includes "room.h" and "mappyal.h"

room.h already includes mappyal.h

You forgot to block duplication of header info

#ifndef MAPPYAL_H
#define MAPPYAL_H

...

#endif

Jakku Night
Member #17,868
June 2020
avatar

Now I tryed to rebuild the project to clean all files wich are duplicated. As I can see, I have to upload the hole project to make the situation more understadable. I blocked the mappyal.h file but it doesn't result. Also I tryed to include into the project the mappyal.c but it gives me the same error.

NOTE: I'm working under Windows 10 and Codeblocks IDE MinGW with Allegro 4.2.2

Thanks for your answers!

DanielH
Member #934
January 2001
avatar

What is the error now?

One issue is that your struct definitions are not the same.

#SelectExpand
1//mappyal.c 2typedef struct { /* Structure for data blocks */ 3long int bgoff, fgoff; /* offsets from start of graphic blocks */ 4long int fgoff2, fgoff3; /* more overlay blocks */ 5unsigned long int user1, user2; /* user long data */ 6unsigned short int user3, user4; /* user short data */ 7unsigned char user5, user6, user7; /* user byte data */ 8unsigned char tl : 1; /* bits for collision detection */ 9unsigned char tr : 1; 10unsigned char bl : 1; 11unsigned char br : 1; 12unsigned char trigger : 1; /* bit to trigger an event */ 13unsigned char unused1 : 1; 14unsigned char unused2 : 1; 15unsigned char unused3 : 1; 16} BLKSTR;

#SelectExpand
1//mappyal.h 2long int bgoff, fgoff; /* offsets from start of graphic blocks */ 3long int fgoff2, fgoff3; /* more overlay blocks */ 4typedef struct { /* Structure for data blocks */ 5unsigned long int user1, user2; /* user long data */ 6unsigned short int user3, user4; /* user short data */ 7unsigned char user5, user6, user7; /* user byte data */ 8unsigned char tl : 1; /* bits for collision detection */ 9unsigned char tr : 1; 10unsigned char bl : 1; 11unsigned char br : 1; 12unsigned char trigger : 1; /* bit to trigger an event */ 13unsigned char unused1 : 1; 14unsigned char unused2 : 1; 15unsigned char unused3 : 1; 16}BLKSTR;

Jakku Night
Member #17,868
June 2020
avatar

Thank you people. I solved the mistake including the mappyal.h file in room.cpp and doing the same for other libaries that were used in this way. Thanks you again.

Post Reply
Go to: