www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/13/13:01:48

From: sl AT psycode DOT com DOT REMOVE_THIS
Newsgroups: comp.os.msdos.djgpp
Subject: DJGPP/GCC bug found
Date: 13 Sep 1998 16:45:21 GMT
Organization: http://www.supernews.com, The World's Usenet: Discussions Start Here
Lines: 66
Message-ID: <iCdMCj1ZQ5j2-pn2-U1bLOKdKkegi@portY12.lanzen.net>
NNTP-Posting-Host: 205.205.70.111
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi,

	I'm unsure who is to blaim for the following bug, but here it is:

---------------
#include <iostream.h>  //Stream library
#include <conio.h>     //Console i/o library
#include <stdio.h>

int x;  //Horizontal position of star
int y;  //Vertical position of star

void Init()
{
  x=40;
  y=12;
}

void Display()
{
  gotoxy(x,y);  //Move cursor (conio)
  cout << "*";  //Display a star (iostream)
}

void Up()
{
  y-=1;  //Up one line
}

void Down()
{
  y+=1;  //Down one line
}

void Left()
{
  x-=1;  //Left one position
}

void Right()
{
  x+=1;  //Right one position
}

//Main program
void main()
{
  setvbuf(stdout, NULL, _IONBF, 0);
  Init();
  Display(); //Display it on the screen
  Up();      //Move it up
  Display(); //Display it again
  Up();      //Move it further up
  Display(); //Display it again
  return;
}
----------------

	In the above example, the compiler complains "return;" is used in a 
case where "main()" is non-void.. But as you can see, it IS declared 
to return void! Anyway, I am using DJGPP 2.1 with GCC 2.8.1.. Try and 
compile the code yourself. You will get the same results.. As for why 
I am using "void main", I am not; this code was provided to me by my 
teacher, so go blaim him <g> .. I know better ..

Gili

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019