View Single Post
  #1   Spotlight this post!  
Unread 04-02-2005, 13:48
gnormhurst's Avatar
gnormhurst gnormhurst is offline
Norm Hurst
AKA: gnorm
#0381 (The Tornadoes)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Trenton, NJ
Posts: 138
gnormhurst will become famous soon enoughgnormhurst will become famous soon enough
syntax error using enum{}

When I compile my code, the compiler says "syntax error" for one of my header files and points to the line shown below:

Code:
enum
{
  START,     <==  this line causes syntax error
  IN_PROGRESS,
  DRIVING,
  TURNING,
  COMPLETE
};
When I rename the variable START to something else like FOOSTART, the error moves down to the next line:

Code:
enum
{
  FOOSTART,
  IN_PROGRESS,  <===  now the error is here
  DRIVING,
  TURNING,
  COMPLETE
};
I figured there must be a name conflict (since I'm using bits of Kevin's code), so I Searched in Project Files... for "IN_PROGRESS", but it is only defined in this one place. No conflict. As I modify each variable in the list, the error moves down the list.

I did a Build All (CTRL-F10) to make sure there wasn't a leftover symbol table. No difference.

As a matter of practicality I renamed all the variables to start with an _underscore, and now it builds just fine. But it bugs me that I can't explain this error.

Any ideas?????

Here's the entire header file:


Code:
#ifndef SCRIPTING_H
#define SCRIPTING_H


#define MAX_SCRIPTS 32 // more than this is an error from parseScript()


struct scriptCommand
{
  int command;
  long int parm_1;
  int parm_2;
  int parm_3;
};

// List of commands
//
enum
{
  S_NAME,    // marks the start of a script
  S_END,     // marks the end of a script
  S_DRIVE,   // <distance>, <maxSpeed>, <maxAccel>
  S_TURN,    // <heading>, <maxSpeed>, <maxAccel>
  S_STOP,
  S_WAIT,    // <counts>
  S_SET_ARM_POSITION,  // <angle>, <speed>, <tolerance>
  S_LIST_END
};


// List of all possible command states 
// Not all are used in every command.
enum
{
  START,
  IN_PROGRESS,
  DRIVING,
  TURNING,
  COMPLETE
};



int parseScript();
int startScript( int scriptCode );
int executingScript( );  // returns 1 if a script is executing.

void backAndForth();
void driveFromStartToLoading();
void knockOffHangingTetra();
void setArmPosition();

unsigned char sDrive();
unsigned char sTurn();


#endif
__________________
Trenton Tornadoes 381
2004 Philadelphia Regional Winners
2006 Xerox Creativity Award
---
My corner of the USPTO.
My favorite error message from gcc: main is usually a function
My favorite error message from Windows: There is not enough disk space available to delete this file.