Thomas Dettbarn - 2023-01-03
<meta charset="UTF-8">
Hello.
Awesome!
 
I am still on holiday, I will have a look once I am home. Thank you! So very very much!
 
Thomas
lmat <dartme@users.sourceforge.net> hat am 02.01.2023 18:27 CET geschrieben:
 
 
---
 
** [bugs:#2] Compilation Errors**
 
**Status:** open
**Group:** v1.0_(example)
**Created:** Mon Jan 02, 2023 05:27 PM UTC by lmat
**Last Updated:** Mon Jan 02, 2023 05:27 PM UTC
**Owner:** nobody
 
 
Attempting to compile this projects yields the following problems at the linking step:
 
 
```
aliens.c: In function ‘render’:
aliens.c:167:31: warning: iteration 10 invokes undefined behavior [-Waggressive-loop-optimizations]
167 | lowest_ship[k]=-1;
| ~~~~~~~~~~~~~~^~~
aliens.c:166:19: note: within this loop
166 | for (k=0;k<11;k++) {
| ~^~~
aliens.c:167:31: warning: ‘__builtin_memset’ forming offset [40, 43] is out of the bounds [0, 40] of object ‘lowest_ship’ with type ‘int[10]’ [-Warray-bounds]
167 | lowest_ship[k]=-1;
| ~~~~~~~~~~~~~~^~~
In file included from aliens.c:25:
aliens.h:50:5: note: ‘lowest_ship’ declared here
50 | int lowest_ship[ALIENS_MAX_NUMBER_X];
| ^~~~~~~~~~~
gcc -onInvaders globals.o view.o aliens.o ufo.o player.o nInvaders.o -lncurses
/usr/bin/ld: ufo.o:(.bss+0x6d0): multiple definition of `aliens'; aliens.o:(.bss+0x6d0): first defined here
/usr/bin/ld: ufo.o:(.bss+0x0): multiple definition of `skill_level'; aliens.o:(.bss+0x0): first defined here
/usr/bin/ld: ufo.o:(.bss+0x4): multiple definition of `level'; aliens.o:(.bss+0x4): first defined here
/usr/bin/ld: ufo.o:(.bss+0x8): multiple definition of `weite'; aliens.o:(.bss+0x8): first defined here
/usr/bin/ld: ufo.o:(.bss+0x20): multiple definition of `bunker'; aliens.o:(.bss+0x20): first defined here
/usr/bin/ld: ufo.o:(.bss+0x540): multiple definition of `alienBlock'; aliens.o:(.bss+0x540): first defined here
/usr/bin/ld: ufo.o:(.bss+0x608): multiple definition of `alienshotnum'; aliens.o:(.bss+0x608): first defined here
/usr/bin/ld: ufo.o:(.bss+0x620): multiple definition of `alienshoty'; aliens.o:(.bss+0x620): first defined here
/usr/bin/ld: ufo.o:(.bss+0x660): multiple definition of `alienshotx'; aliens.o:(.bss+0x660): first defined here
/usr/bin/ld: ufo.o:(.bss+0x6a0): multiple definition of `lowest_ship'; aliens.o:(.bss+0x6a0): first defined here
/usr/bin/ld: ufo.o:(.bss+0x6c8): multiple definition of `shipnum'; aliens.o:(.bss+0x6c8): first defined here
/usr/bin/ld: player.o:(.bss+0x6f0): multiple definition of `aliens'; aliens.o:(.bss+0x6d0): first defined here
/usr/bin/ld: player.o:(.bss+0x18): multiple definition of `skill_level'; aliens.o:(.bss+0x0): first defined here
/usr/bin/ld: player.o:(.bss+0x6e8): multiple definition of `shipnum'; aliens.o:(.bss+0x6c8): first defined here
/usr/bin/ld: player.o:(.bss+0x1c): multiple definition of `level'; aliens.o:(.bss+0x4): first defined here
/usr/bin/ld: player.o:(.bss+0x20): multiple definition of `weite'; aliens.o:(.bss+0x8): first defined here
/usr/bin/ld: player.o:(.bss+0x28): multiple definition of `ufo'; ufo.o:(.bss+0x6e8): first defined here
/usr/bin/ld: player.o:(.bss+0x40): multiple definition of `bunker'; aliens.o:(.bss+0x20): first defined here
/usr/bin/ld: player.o:(.bss+0x560): multiple definition of `alienBlock'; aliens.o:(.bss+0x540): first defined here
/usr/bin/ld: player.o:(.bss+0x628): multiple definition of `alienshotnum'; aliens.o:(.bss+0x608): first defined here
/usr/bin/ld: player.o:(.bss+0x640): multiple definition of `alienshoty'; aliens.o:(.bss+0x620): first defined here
/usr/bin/ld: player.o:(.bss+0x680): multiple definition of `alienshotx'; aliens.o:(.bss+0x660): first defined here
/usr/bin/ld: player.o:(.bss+0x6c0): multiple definition of `lowest_ship'; aliens.o:(.bss+0x6a0): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x6f0): multiple definition of `weite'; aliens.o:(.bss+0x8): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x6ec): multiple definition of `level'; aliens.o:(.bss+0x4): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x6e8): multiple definition of `skill_level'; aliens.o:(.bss+0x0): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x6c8): multiple definition of `shipnum'; aliens.o:(.bss+0x6c8): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x18): multiple definition of `ufo'; ufo.o:(.bss+0x6e8): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x20): multiple definition of `bunker'; aliens.o:(.bss+0x20): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x540): multiple definition of `alienBlock'; aliens.o:(.bss+0x540): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x608): multiple definition of `alienshotnum'; aliens.o:(.bss+0x608): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x620): multiple definition of `alienshoty'; aliens.o:(.bss+0x620): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x660): multiple definition of `alienshotx'; aliens.o:(.bss+0x660): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x6a0): multiple definition of `lowest_ship'; aliens.o:(.bss+0x6a0): first defined here
/usr/bin/ld: nInvaders.o:(.bss+0x6d0): multiple definition of `aliens'; aliens.o:(.bss+0x6d0): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:11: nInvaders] Error 1
```
 
The following changes fix the errors:
 
```
commit 98cab46bff3ff124bb6428698f9987f87eefc619
Author: lmat <dartme18@gmail.com>
Date: Mon Jan 2 12:25:28 2023 -0500
 
Corrected compilation errors
 
diff --git a/aliens.c b/aliens.c
index fa87c5c..6c42676 100644
--- a/aliens.c
+++ b/aliens.c
@@ -26,6 +26,19 @@
#include "player.h"
#include "nInvaders.h"
 
+Aliens aliens;
+
+int shipnum;
+
+// todo: move to structure
+int lowest_ship[ALIENS_MAX_NUMBER_X];
+int alienshotx[ALIENS_MAX_MISSILES];
+int alienshoty[ALIENS_MAX_MISSILES];
+int alienshotnum;
+int alienBlock[ALIENS_MAX_NUMBER_Y][ALIENS_MAX_NUMBER_X];
+
+int bunker[BUNKERHEIGHT][BUNKERWIDTH + 1];
+
/**
* initialize aliens attributes
*/
@@ -163,7 +176,7 @@ void render()
aliens.right=-1;
aliens.bottom=-1;
shipnum=0;
- for (k=0;k<11;k++) {
+ for (k=0;k<ALIENS_MAX_NUMBER_X;k++) {
lowest_ship[k]=-1;
}
 
diff --git a/aliens.h b/aliens.h
index 040d93f..a746414 100644
--- a/aliens.h
+++ b/aliens.h
@@ -37,23 +37,23 @@ struct Aliens {
int bottom;
int speed; // 0: no movement; 1: one per turn; etc.
};
-
-Aliens aliens;
-
-int shipnum;
+
+extern Aliens aliens;
+
+extern int shipnum;
 
#define ALIENS_MAX_NUMBER_X 10
#define ALIENS_MAX_NUMBER_Y 5
#define ALIENS_MAX_MISSILES 10
 
// todo: move to structure
-int lowest_ship[ALIENS_MAX_NUMBER_X];
-int alienshotx[ALIENS_MAX_MISSILES];
-int alienshoty[ALIENS_MAX_MISSILES];
-int alienshotnum;
-int alienBlock[ALIENS_MAX_NUMBER_Y][ALIENS_MAX_NUMBER_X];
+extern int lowest_ship[ALIENS_MAX_NUMBER_X];
+extern int alienshotx[ALIENS_MAX_MISSILES];
+extern int alienshoty[ALIENS_MAX_MISSILES];
+extern int alienshotnum;
+extern int alienBlock[ALIENS_MAX_NUMBER_Y][ALIENS_MAX_NUMBER_X];
 
-int bunker[BUNKERHEIGHT][BUNKERWIDTH + 1];
+extern int bunker[BUNKERHEIGHT][BUNKERWIDTH + 1];
 
 
void aliensReset();
diff --git a/nInvaders.c b/nInvaders.c
index 793139c..2afe398 100644
--- a/nInvaders.c
+++ b/nInvaders.c
@@ -32,6 +32,11 @@
 
#define FPS 50
 
+// todo: let's try to not having to declare these "public"
+int weite;
+int level;
+int skill_level;
+
int lives;
long score;
int status; // status handled in timer
diff --git a/nInvaders.h b/nInvaders.h
index 1161321..161d370 100644
--- a/nInvaders.h
+++ b/nInvaders.h
@@ -46,10 +46,10 @@ void drawscore();
void doScoring(int alienType);
 
// todo: let's try to not having to declare these "public"
-int weite;
-int level;
-int skill_level;
-
+extern int weite;
+extern int level;
+extern int skill_level;
+
// included from globals.h
extern void doSleep();
extern void showUsage();
diff --git a/ufo.c b/ufo.c
index 928872b..1d747c0 100644
--- a/ufo.c
+++ b/ufo.c
@@ -27,6 +27,7 @@
#include "nInvaders.h"
 
static int fShowUfo = 0;
+Ufo ufo;
 
/**
* initialize ufo attributes
diff --git a/ufo.h b/ufo.h
index 60dc493..05447da 100644
--- a/ufo.h
+++ b/ufo.h
@@ -34,7 +34,7 @@ struct Ufo {
int posY; // vertical position of aliens
};
 
-Ufo ufo;
+extern Ufo ufo;
 
void ufoReset();
int ufoShowUfo();
```
 
Please incorporate these changes or let me know if anything should be changed.
 
It looks like the code repository for this project is read-only at this point and the maintainers are perhaps no longer interested in maintaining the project. If that is the case, feel free to transfer the project to me and I would be happy to create a new not-read-only repository on the project and incorporate the changes.
 
 
---
 
Sent from sourceforge.net because you indicated interest in <https://sourceforge.net/p/ninvaders/bugs/2/>
 
 
 
To unsubscribe from further messages, please visit <https://sourceforge.net/auth/subscriptions/>