public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* compiling issue
@ 2023-01-21  5:19 internetking425
  2023-01-21  7:47 ` Arrigo Marchiori
  2023-01-21 15:35 ` Thomas Wolff
  0 siblings, 2 replies; 4+ messages in thread
From: internetking425 @ 2023-01-21  5:19 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 4253 bytes --]

The file here for a game I wanted to use is
http://www.ifarchive.org/if-archive/games/source/Adventure2.5.tar.gz and it
all compiled but one file getting the error is init.c  as follows: 

 

 

gcc -O  -c init.c

init.c:167:1: warning: return type defaults to 'int' [-Wimplicit-int]

  167 | initialise() {

      | ^~~~~~~~~~

init.c: In function 'initialise':

init.c:169:13: warning: implicit declaration of function 'quick_init'
[-Wimplicit-function-declaration]

  169 |         if(!quick_init()){raw_init(); report(); quick_save();}

      |             ^~~~~~~~~~

init.c:169:27: warning: implicit declaration of function 'raw_init'
[-Wimplicit-function-declaration]

  169 |         if(!quick_init()){raw_init(); report(); quick_save();}

      |                           ^~~~~~~~

init.c:169:39: warning: implicit declaration of function 'report'
[-Wimplicit-function-declaration]

  169 |         if(!quick_init()){raw_init(); report(); quick_save();}

      |                                       ^~~~~~

init.c:169:49: warning: implicit declaration of function 'quick_save'
[-Wimplicit-function-declaration]

  169 |         if(!quick_init()){raw_init(); report(); quick_save();}

      |                                                 ^~~~~~~~~~

init.c:170:9: warning: implicit declaration of function 'finish_init'
[-Wimplicit-function-declaration]

  170 |         finish_init();

      |         ^~~~~~~~~~~

init.c: At top level:

init.c:173:8: warning: return type defaults to 'int' [-Wimplicit-int]

  173 | static raw_init() {

      |        ^~~~~~~~

init.c:173:8: error: static declaration of 'raw_init' follows non-static
declaration

init.c:169:27: note: previous implicit declaration of 'raw_init' with type
'int()'

  169 |         if(!quick_init()){raw_init(); report(); quick_save();}

      |                           ^~~~~~~~

init.c:369:8: warning: return type defaults to 'int' [-Wimplicit-int]

  369 | static finish_init() {

      |        ^~~~~~~~~~~

init.c:369:8: error: static declaration of 'finish_init' follows non-static
declaration

init.c:170:9: note: previous implicit declaration of 'finish_init' with type
'int()'

  170 |         finish_init();

      |         ^~~~~~~~~~~

init.c:593:8: warning: return type defaults to 'int' [-Wimplicit-int]

  593 | static report() {

      |        ^~~~~~

init.c:593:8: error: static declaration of 'report' follows non-static
declaration

init.c:169:39: note: previous implicit declaration of 'report' with type
'int()'

  169 |         if(!quick_init()){raw_init(); report(); quick_save();}

      |                                       ^~~~~~

init.c:635:8: warning: return type defaults to 'int' [-Wimplicit-int]

  635 | static quick_init() {

      |        ^~~~~~~~~~

init.c:635:8: error: static declaration of 'quick_init' follows non-static
declaration

init.c:169:13: note: previous implicit declaration of 'quick_init' with type
'int()'

  169 |         if(!quick_init()){raw_init(); report(); quick_save();}

      |             ^~~~~~~~~~

init.c: In function 'quick_init':

init.c:648:9: warning: implicit declaration of function 'quick_io'; did you
mean 'quick_init'? [-Wimplicit-function-declaration]

  648 |         quick_io();

      |         ^~~~~~~~

      |         quick_init

init.c: At top level:

init.c:655:8: warning: return type defaults to 'int' [-Wimplicit-int]

  655 | static quick_save() {

      |        ^~~~~~~~~~

init.c:655:8: error: static declaration of 'quick_save' follows non-static
declaration

init.c:169:49: note: previous implicit declaration of 'quick_save' with type
'int()'

  169 |         if(!quick_init()){raw_init(); report(); quick_save();}

      |                                                 ^~~~~~~~~~

init.c:667:8: warning: return type defaults to 'int' [-Wimplicit-int]

  667 | static quick_io() {

      |        ^~~~~~~~

init.c:667:8: error: static declaration of 'quick_io' follows non-static
declaration

init.c:648:9: note: previous implicit declaration of 'quick_io' with type
'int()'

  648 |         quick_io();

      |         ^~~~~~~~

make: *** [Makefile:8: init.o] Error 1

 

 

so any tips or suggestions to fix this would be appreciated.

 

Thank you. 

 

 

 

 

 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: compiling issue
  2023-01-21  5:19 compiling issue internetking425
@ 2023-01-21  7:47 ` Arrigo Marchiori
  2023-01-21 13:07   ` Jon Turney
  2023-01-21 15:35 ` Thomas Wolff
  1 sibling, 1 reply; 4+ messages in thread
From: Arrigo Marchiori @ 2023-01-21  7:47 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1857 bytes --]

Hello,

On Fri, Jan 20, 2023 at 09:19:49PM -0800, Nathan via Cygwin wrote:

> The file here for a game I wanted to use is
> http://www.ifarchive.org/if-archive/games/source/Adventure2.5.tar.gz and it
> all compiled but one file getting the error is init.c  as follows: 
> 
> gcc -O  -c init.c
> 
> init.c:167:1: warning: return type defaults to 'int' [-Wimplicit-int]
>   167 | initialise() {
>       | ^~~~~~~~~~
> 
> init.c: In function 'initialise':
> init.c:169:13: warning: implicit declaration of function 'quick_init'
> [-Wimplicit-function-declaration]
>   169 |         if(!quick_init()){raw_init(); report(); quick_save();}
>       |             ^~~~~~~~~~
> 
> init.c:169:27: warning: implicit declaration of function 'raw_init'
> [-Wimplicit-function-declaration]
>   169 |         if(!quick_init()){raw_init(); report(); quick_save();}
>       |                           ^~~~~~~~
>

[...]

> init.c: At top level:
> init.c:173:8: warning: return type defaults to 'int' [-Wimplicit-int]
>   173 | static raw_init() {
>       |        ^~~~~~~~
> 
> init.c:173:8: error: static declaration of 'raw_init' follows non-static
> declaration
> init.c:169:27: note: previous implicit declaration of 'raw_init' with type
> 'int()'
>   169 |         if(!quick_init()){raw_init(); report(); quick_save();}
>       |                           ^~~~~~~~

[...]

> so any tips or suggestions to fix this would be appreciated.

I guess that this code was written to work older compilers, that
allowed different (looser) constructs.

The problem is not Cygwin, but rather the compiler installed with
Cygwin.

For this reason, what follows is off-topic here.

The attached patch should allow compilation with today's compilers.
Copy the file in the same directory as the sources and run:

 $ patch < adventure.patch

I hope this helps.

Best regards,
-- 
Arrigo

[-- Attachment #2: adventure.patch --]
[-- Type: text/x-diff, Size: 1826 bytes --]

--- init.c.orig	1996-01-29 23:21:02.000000000 +0100
+++ init.c	2023-01-21 08:35:20.788823913 +0100
@@ -164,13 +164,19 @@
  *	%B = VARIABLE NUMBER OF BLANKS
  *	%! = THE ENTIRE MESSAGE SHOULD BE SUPPRESSED */
 
-initialise() {
+static int quick_init();
+static int raw_init();
+static int finish_init();
+static void report();
+static int quick_save();
+
+void initialise() {
 	printf("Initialising...\n");
 	if(!quick_init()){raw_init(); report(); quick_save();}
 	finish_init();
 }
 
-static raw_init() {
+static int raw_init() {
 	printf("Couldn't find adventure.data, using adventure.text...\n");
 
 /*  CLEAR OUT THE VARIOUS TEXT-POINTER ARRAYS.  ALL TEXT IS STORED IN ARRAY
@@ -366,7 +372,7 @@
  *  CORRECT LINK TO USE.)  ABB IS ZEROED; IT CONTROLS WHETHER THE ABBREVIATED
  *  DESCRIPTION IS PRINTED.  COUNTS MOD 5 UNLESS "LOOK" IS USED. */
 
-static finish_init() {
+static int finish_init() {
 	/* 1101 */ for (I=1; I<=100; I++) {
 	PLACE[I]=0;
 	PROP[I]=0;
@@ -590,7 +596,7 @@
 
 /*  REPORT ON AMOUNT OF ARRAYS ACTUALLY USED, TO PERMIT REDUCTIONS. */
 
-static report() {
+static void report() {
 	/* 1998 */ for (K=1; K<=LOCSIZ; K++) {
 	KK=LOCSIZ+1-K;
 	if(LTEXT[KK] != 0) goto L1997;
@@ -631,8 +637,9 @@
 
 static void quick_item(long*);
 static void quick_array(long*, long);
+static int quick_io();
 
-static quick_init() {
+static int quick_init() {
 #ifdef AMIGA
 	f = fopen("ram:adventure.data", READ_MODE);
 #else
@@ -652,7 +659,7 @@
 	return(init_cksum == 0);
 }
 
-static quick_save() {
+static int quick_save() {
 	printf("Writing adventure.data...\n");
 	f = fopen("adventure.data",WRITE_MODE);
 	if(f == NULL){printf("Can't open file!\n"); return(0);}
@@ -664,7 +671,7 @@
 	return(0);
 }
 
-static quick_io() {
+static int quick_io() {
 	quick_item(&LINUSE);
 	quick_item(&TRVS);
 	quick_item(&CLSSES);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: compiling issue
  2023-01-21  7:47 ` Arrigo Marchiori
@ 2023-01-21 13:07   ` Jon Turney
  0 siblings, 0 replies; 4+ messages in thread
From: Jon Turney @ 2023-01-21 13:07 UTC (permalink / raw)
  To: internetking425, The Cygwin Mailing List

On 21/01/2023 07:47, Arrigo Marchiori via Cygwin wrote:
> On Fri, Jan 20, 2023 at 09:19:49PM -0800, Nathan via Cygwin wrote:
> 
>> The file here for a game I wanted to use is
>> http://www.ifarchive.org/if-archive/games/source/Adventure2.5.tar.gz and it
>> all compiled but one file getting the error is init.c  as follows:
>>
[...]
> 
>> so any tips or suggestions to fix this would be appreciated.

You might also find the package 'nfrotz' of some interest.

https://cygwin.com/packages/summary/nfrotz-src.html

> I guess that this code was written to work older compilers, that
> allowed different (looser) constructs.
> 
> The problem is not Cygwin, but rather the compiler installed with
> Cygwin.
> 
> For this reason, what follows is off-topic here.
> 
> The attached patch should allow compilation with today's compilers.
> Copy the file in the same directory as the sources and run:
> 
>   $ patch < adventure.patch
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: compiling issue
  2023-01-21  5:19 compiling issue internetking425
  2023-01-21  7:47 ` Arrigo Marchiori
@ 2023-01-21 15:35 ` Thomas Wolff
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Wolff @ 2023-01-21 15:35 UTC (permalink / raw)
  To: cygwin



Am 21.01.2023 um 06:19 schrieb Nathan via Cygwin:
> The file here for a game I wanted to use is
> http://www.ifarchive.org/if-archive/games/source/Adventure2.5.tar.gz and it
> all compiled but one file getting the error is init.c  as follows:
Leaving out result types isn't legal C nowadays.
You could compile with
gcc -std=c90

> gcc -O  -c init.c
>
> init.c:167:1: warning: return type defaults to 'int' [-Wimplicit-int]
>
>    167 | initialise() {
>
>        | ^~~~~~~~~~
>
> init.c: In function 'initialise':
>
> init.c:169:13: warning: implicit declaration of function 'quick_init'
> [-Wimplicit-function-declaration]
>
>    169 |         if(!quick_init()){raw_init(); report(); quick_save();}
>
>        |             ^~~~~~~~~~
>
> init.c:169:27: warning: implicit declaration of function 'raw_init'
> [-Wimplicit-function-declaration]
>
>    169 |         if(!quick_init()){raw_init(); report(); quick_save();}
>
>        |                           ^~~~~~~~
>
> init.c:169:39: warning: implicit declaration of function 'report'
> [-Wimplicit-function-declaration]
>
>    169 |         if(!quick_init()){raw_init(); report(); quick_save();}
>
>        |                                       ^~~~~~
>
> init.c:169:49: warning: implicit declaration of function 'quick_save'
> [-Wimplicit-function-declaration]
>
>    169 |         if(!quick_init()){raw_init(); report(); quick_save();}
>
>        |                                                 ^~~~~~~~~~
>
> init.c:170:9: warning: implicit declaration of function 'finish_init'
> [-Wimplicit-function-declaration]
>
>    170 |         finish_init();
>
>        |         ^~~~~~~~~~~
>
> init.c: At top level:
>
> init.c:173:8: warning: return type defaults to 'int' [-Wimplicit-int]
>
>    173 | static raw_init() {
>
>        |        ^~~~~~~~
>
> init.c:173:8: error: static declaration of 'raw_init' follows non-static
> declaration
>
> init.c:169:27: note: previous implicit declaration of 'raw_init' with type
> 'int()'
>
>    169 |         if(!quick_init()){raw_init(); report(); quick_save();}
>
>        |                           ^~~~~~~~
>
> init.c:369:8: warning: return type defaults to 'int' [-Wimplicit-int]
>
>    369 | static finish_init() {
>
>        |        ^~~~~~~~~~~
>
> init.c:369:8: error: static declaration of 'finish_init' follows non-static
> declaration
>
> init.c:170:9: note: previous implicit declaration of 'finish_init' with type
> 'int()'
>
>    170 |         finish_init();
>
>        |         ^~~~~~~~~~~
>
> init.c:593:8: warning: return type defaults to 'int' [-Wimplicit-int]
>
>    593 | static report() {
>
>        |        ^~~~~~
>
> init.c:593:8: error: static declaration of 'report' follows non-static
> declaration
>
> init.c:169:39: note: previous implicit declaration of 'report' with type
> 'int()'
>
>    169 |         if(!quick_init()){raw_init(); report(); quick_save();}
>
>        |                                       ^~~~~~
>
> init.c:635:8: warning: return type defaults to 'int' [-Wimplicit-int]
>
>    635 | static quick_init() {
>
>        |        ^~~~~~~~~~
>
> init.c:635:8: error: static declaration of 'quick_init' follows non-static
> declaration
>
> init.c:169:13: note: previous implicit declaration of 'quick_init' with type
> 'int()'
>
>    169 |         if(!quick_init()){raw_init(); report(); quick_save();}
>
>        |             ^~~~~~~~~~
>
> init.c: In function 'quick_init':
>
> init.c:648:9: warning: implicit declaration of function 'quick_io'; did you
> mean 'quick_init'? [-Wimplicit-function-declaration]
>
>    648 |         quick_io();
>
>        |         ^~~~~~~~
>
>        |         quick_init
>
> init.c: At top level:
>
> init.c:655:8: warning: return type defaults to 'int' [-Wimplicit-int]
>
>    655 | static quick_save() {
>
>        |        ^~~~~~~~~~
>
> init.c:655:8: error: static declaration of 'quick_save' follows non-static
> declaration
>
> init.c:169:49: note: previous implicit declaration of 'quick_save' with type
> 'int()'
>
>    169 |         if(!quick_init()){raw_init(); report(); quick_save();}
>
>        |                                                 ^~~~~~~~~~
>
> init.c:667:8: warning: return type defaults to 'int' [-Wimplicit-int]
>
>    667 | static quick_io() {
>
>        |        ^~~~~~~~
>
> init.c:667:8: error: static declaration of 'quick_io' follows non-static
> declaration
>
> init.c:648:9: note: previous implicit declaration of 'quick_io' with type
> 'int()'
>
>    648 |         quick_io();
>
>        |         ^~~~~~~~
>
> make: *** [Makefile:8: init.o] Error 1
>
>   
>
>   
>
> so any tips or suggestions to fix this would be appreciated.
>
>   
>
> Thank you.
>
>   
>
>   
>
>   
>
>   
>
>   
>
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-21 15:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-21  5:19 compiling issue internetking425
2023-01-21  7:47 ` Arrigo Marchiori
2023-01-21 13:07   ` Jon Turney
2023-01-21 15:35 ` Thomas Wolff

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).