Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (AndrewAMD, TipmyPip), 12,420 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Syntax Error #285005
08/16/09 15:59
08/16/09 15:59
Joined: Aug 2009
Posts: 11
A
alwaysblack Offline OP
Newbie
alwaysblack  Offline OP
Newbie
A

Joined: Aug 2009
Posts: 11
Can anyone see why these lines fail to compile with a syntax error?

char* data = {'A','B','C','D','E','F','G','H','I','J'};
int pointer = {0,1,2,3,4,5,6,7,8,9};


If there's nothing wrong with the actual syntax (I can't see anything), what other reason could there be for a syntax error compiling with Lite C?

Re: Syntax Error [Re: alwaysblack] #285006
08/16/09 16:04
08/16/09 16:04
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
you haven't specified that size of the array
int data[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

Re: Syntax Error [Re: MrGuest] #285007
08/16/09 16:07
08/16/09 16:07
Joined: Aug 2009
Posts: 11
A
alwaysblack Offline OP
Newbie
alwaysblack  Offline OP
Newbie
A

Joined: Aug 2009
Posts: 11
Ah, thank you.

I took the lines from a tutorial about lists here: http://www.opserver.de/coni_users/web_users/pirvu/au/tutorials.html

I guess either the author forgot or else is using something with a different syntax.

Re: Syntax Error [Re: alwaysblack] #286137
08/23/09 11:37
08/23/09 11:37
Joined: Aug 2009
Posts: 11
A
alwaysblack Offline OP
Newbie
alwaysblack  Offline OP
Newbie
A

Joined: Aug 2009
Posts: 11
Argh. Another one, although less basic, I think.
Code:
//a function to visualize an item on a panel
void item_visualize( Inventory *inventory, Panel *panel ) {
panel->bmap = inventory->image;
}



Re: Syntax Error [Re: alwaysblack] #286138
08/23/09 11:46
08/23/09 11:46
Joined: Dec 2008
Posts: 271
Saturnus Offline
Member
Saturnus  Offline
Member

Joined: Dec 2008
Posts: 271
If "Panel" is meant to be the predefined acknex struct, which is named "PANEL", it should be "PANEL *panel" instead of "Panel *panel".

Re: Syntax Error [Re: Saturnus] #286139
08/23/09 11:48
08/23/09 11:48
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
As Kombucha says. Pretty much everything in Lite-C is case-sensitive...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Syntax Error [Re: EvilSOB] #286141
08/23/09 11:54
08/23/09 11:54
Joined: Aug 2009
Posts: 11
A
alwaysblack Offline OP
Newbie
alwaysblack  Offline OP
Newbie
A

Joined: Aug 2009
Posts: 11
I tried that, no luck frown

Here's the rest of the file in case it matters...

Code:
////////////////////////////////////////////////////////////////////
//
//		Theseus Engine V1.0
//
////////////////////////////////////////////////////////////////////

#include <acknex.h>
#include <default.c>
#include <litec.h>

//ROOM.c

typedef struct 
{
  int roomNumber;
  BMAP* image;
  STRING* name;

} ROOM;

/*
//a function to visualize an room on a panel
void room_visualize(DUNGEON* dungeon, PANEL* panel)
{
  panel->bmap = dungeon->image;
}
*/

//a function to visualize an item on a panel
void item_visualize( Inventory* inventory, PANEL* panel ) {
  panel->bmap = inventory->image;
}


//ROOM creation function, returns pointer to the newly created ROOM
ROOM* room_create( int number, String* imageName ) 
{
  ROOM* room = malloc( sizeof( ROOM ) );
  
  //always fill ALL the room's properties immediately after!
  room->roomNumber = number;
  room->image = bmap_create( imageName );
  room->name = imageName;
  
  return room; //return the new room back
}


//function to remove an room
void room_remove( ROOM* room ) 
{
  ptr_remove( room->image ); //remove bitmap first
  ptr_remove( room->name ); //remove name
  free( room ); //THEN remove room
}



Re: Syntax Error [Re: alwaysblack] #286145
08/23/09 12:11
08/23/09 12:11
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Well, try completeing your code before compiling it.
At a glance I can see that neither "DUNGEON" nor "Inventory"
types exist yet. (ie you haven defined their structs yet)

So wither there is still some code missing, you you need to define
your structs for "DUNGEON" and "Inventory" types before anything
will even get close to compiling, let alone working.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Syntax Error [Re: EvilSOB] #286146
08/23/09 12:24
08/23/09 12:24
Joined: Aug 2009
Posts: 11
A
alwaysblack Offline OP
Newbie
alwaysblack  Offline OP
Newbie
A

Joined: Aug 2009
Posts: 11
OK, apologies, I was trying to avoid flooding the board with files if it was just another simple misunderstanding of syntax on my part.

To present a fuller explanation... I'm trying to get Joozey's 'structured programming' example to work, firstly to try and understand what's happening and secondly to maybe tweak the principles he introduced to suit my own project.

Here are all of the files.

The 'room' definition -

Code:
//ROOM.c

typedef struct 
{
  int roomNumber;
  BMAP* image;
  STRING* name;

} ROOM;


//a function to visualize an room on a panel
void room_visualize(DUNGEON* dungeon, PANEL* panel)
{
  panel->bmap = dungeon->image;
}


//ROOM creation function, returns pointer to the newly created ROOM
ROOM* room_create( int number, String* imageName ) 
{
  ROOM* room = malloc( sizeof( ROOM ) );
  
  //always fill ALL the room's properties immediately after!
  room->roomNumber = number;
  room->image = bmap_create( imageName );
  room->name = imageName;
  
  return room; //return the new room back
}


//function to remove an room
void room_remove( ROOM* room ) 
{
  ptr_remove( room->image ); //remove bitmap first
  ptr_remove( room->name ); //remove name
  free( room ); //THEN remove room
}



The 'dungeon' definition -

Code:
//DUNGEON.c
typedef struct 
{  
  bool alive;

  Panel *panel;

  ROOM *item1;
  ROOM *room2;
  
} DUNGEON;


//function to keep the inventory running and catch input
void inventory_run( DUNGEON *inventory ) 
{
    //infinite loop
  //in order to check if the object still exists and prevent empty pointer errors,
  //you can best add an "alive" state, just add an "alive" boolean in the structure, and check it here
  //after the while, call the inventory_remove function to fully destroy
  //We simply make an inventory_kill() function, and set the boolean to false to kill the object
  while( inventory->alive ) { //as long as the inventory is alive, keep loopin'

    //when we press key_1, show room1
    if( key_1 ) 
    {
      room_visualize( inventory->room1, inventory->panel ); //remember this function in the room code?
    }

    //when we press key_2, show room2
    if( key_2 ) 
    {
      room_visualize( inventory->room2, inventory->panel );
    }

    wait( 1 );
  }

  inventory_remove( inventory ); //the object is dead, remove it!
}


//function kill
void dungeon_kill( DUNGEON *dungeon ) 
{
  dungeon->alive = false;
}


//function to create a new dungeon
DUNGEON *dungeon_create() 
{
  //allocate new dungeon structure
  DUNGEON *dungeon = malloc( sizeof( DUNGEON ) );
 
  //once again, fill all its parameters immediately after
  dungeon->alive = true; //we set this object to alive first!
  dungeon->panel = pan_create("bla");
  dungeon->room1 = room_create( 1, "room1.tga" ); //easily create an room
  dungeon->room2 = room_create( 2, "room2.tga" );

  //in addition to the room code, the dungeon code catches player input
  //this run function handles this input, and loops infinitely
  dungeon_run( dungeon );

  return dungeon; //give back the dungeon
}


void dungeon_remove( DUNGEON *dungeon ) 
{
  room_remove( dungeon->room1 ); //remove room1 first
  room_remove( dungeon->room2 ); //remove room2
  ptr_remove( dungeon->panel ); //don't forget to remove the panel too
  free( dungeon ); //THEN remove dungeon safely
}



The main -

Code:
////////////////////////////////////////////////////////////////////
//
//		Theseus Engine V1.0
//
////////////////////////////////////////////////////////////////////

#include <acknex.h>
#include <default.c>
#include <litec.h>


#include "panels.c"
#include "room.c"
#include "dungeon.c"
////////////////////////////////////////////////////////////////////

void main() 
{

  //create a new inventory!
  DUNGEON *dungeon = dungeon_create();

  //main loop (a little dirty, but forgiveable for now :) )
  while( 1 ) {
    
    //when we press q, remove the inventory
    if( key_q ) 
    {
      dungeon_remove( dungeon ); //this should go smooth without errors...
    }

    wait( 1 );
  }
}



As you can see, I have just taken Joozey's example files and renamed the objects to suit the purpose for which I intend to develop them. Joozey's unedited files give a syntax error in the same place, when I compile main.

Code:
Error in 'room.c' line 20: syntax error

<void item_visualize( Inventory* inventory, PANEL* panel ) {
>

.
Can't compile MAIN.C





Last edited by alwaysblack; 08/23/09 12:26.
Re: Syntax Error [Re: alwaysblack] #286148
08/23/09 13:20
08/23/09 13:20
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Originally Posted By: alwaysblack
OK, apologies, I was trying to avoid flooding the board with files if it was just another simple misunderstanding of syntax on my part.
Dont worry about that, just use the [spoiler] code to 'hide' thecode from regular view.
After all, if you dont post code, ... , how can we STEAL it!

But anyways, I think I see the problem, but Im not sure. With your problem code...
Code:
//a function to visualize an item on a panel
void item_visualize( Inventory *inventory, Panel *panel ) {
panel->bmap = inventory->image;
}

I STILL cant find a struct for your "Inventory" type.
And looking at the rest of your code is tricky, cause your 'changed' type-names are a little odd and confusing.
But I THINK this code should be
Code:
//a function to visualize an item on a panel
void item_visualize( DUNGEON *inventory, Panel *panel ) {
panel->bmap = inventory->image;
}


Let me know how that goes...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Page 1 of 2 1 2

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1