error: expected constructor, destructor on compile

im attempting to compile an MTX contorol program for my rainbowduino, but the compiler tells me this:

Rainbowduino.cpp:0: error: expected, constructor, destructor, or type conversion before '/' token

and im not sure how i go about fixing that, i am using arduino 0022, heres the code:

the PDE:

/*
 * Firmware.h version 1.02 - to run mtXcontrol Rainbowduino/Arduino
 * Copyright (c) 2009 Tobias Bielohlawek -> http://www.rngtng.com/mtxcontrol
 *
 */

#include <EEPROM.h>

/* 
 * Rainbowduino.h && Rainbowduino.cpp are symbolically linked to make it compile right from the beginning.
 * It's way more clean if you move "rainbowduino" Folder (including Rainbowduino.h && Rainbowduino.cpp) to you Arduino library 
 * and remove those links
 */
#include "Rainbowduino.h"

#define LIVE 0
#define STANDALONE 1

#define BAUD_RATE 9600

#define CRTL 255
#define RESET 255

#define WRITE_FRAME 253
#define WRITE_EEPROM 252
#define READ_EEPROM 251

#define SPEED 249
#define SPEED_INC 128 //B1000 0000
#define SPEED_DEC 1   //B0000 0001

#define DEFAULT_SPEED 5000

Rainbowduino rainbow = Rainbowduino(10);  //max 10 Frames

//running mode
byte mode = STANDALONE;

word current_delay = 0;
word current_speed = DEFAULT_SPEED;

void setup_timer()               
{
  TCCR2A |= (1 << WGM21) | (1 << WGM20);   
  TCCR2B |= (1<<CS22); // by clk/64
  TCCR2B &= ~((1<<CS21) | (1<<CS20));   // by clk/64
  TCCR2B &= ~((1<<WGM21) | (1<<WGM20));   // Use normal mode
  ASSR |= (0<<AS2);       // Use internal clock - external clock not used in Arduino
  TIMSK2 |= (1<<TOIE2) | (0<<OCIE2B);   //Timer2 Overflow Interrupt Enable
  TCNT2 = 0xE7; //gamma value
  sei();   
}

//Timer2 overflow interrupt vector handler
ISR(TIMER2_OVF_vect) {
  TCNT2 = 0xE7; //gamma value
  rainbow.draw();
}

void setup() {
  Serial.begin(BAUD_RATE);
  load_from_eeprom(0);
  reset();
  setup_timer();
}

void reset() {
  rainbow.reset();
  current_delay = 0;
  current_speed = DEFAULT_SPEED;
  mode = STANDALONE;
}

void loop() {
  check_serial();
  next_frame();
}

void next_frame() {
  if( mode == LIVE ) return;
  if(current_delay < 1) {
    current_delay = current_speed;
    rainbow.next_frame();
  }
  current_delay--;
}

void check_serial() {
  if( !Serial.available() ) return;
  byte value = read_serial();
  if( value == CRTL ) {
    switch( wait_and_read_serial() ) {
    case RESET:
      load_from_eeprom(0);
      reset();
      break;
    case WRITE_EEPROM: // TODO: add handshake sequence here???
      write_to_eeprom(0);
      break;
    case READ_EEPROM:
      send_eeprom(0);
      break;
    case WRITE_FRAME:
      write_to_current_frame();
      mode = LIVE;
      break;
    case SPEED:
      value = wait_and_read_serial();
      if( value == SPEED_INC && current_speed > 100 ) current_speed -= 100;
      if( value == SPEED_DEC ) current_speed += 100;
      break;
    }
  }
}

byte read_serial() {
  return Serial.read();
}

byte wait_and_read_serial() {
  while( !Serial.available() );
  return read_serial();
}

void write_to_current_frame() {
  for(byte row = 0; row < rainbow.num_rows; row++) {
    rainbow.set_current_frame_row(row, wait_and_read_serial());
  }
}

void write_to_eeprom( word addr ) {
  word num_frames = wait_and_read_serial();
  EEPROM.write(addr++, num_frames);

  for( word frame_nr = 0; frame_nr < num_frames; frame_nr++ ) {
    for( byte row = 0; row < rainbow.num_rows; row++ ) {
      EEPROM.write(addr++, wait_and_read_serial()); //TODO: this will likely fail if addr is bigger than we actually can adress
    }
  }
}

void send_eeprom( word addr ) {
  word num_frames = EEPROM.read(addr++); 
  num_frames = min(rainbow.max_num_frames, num_frames);
  Serial.write(num_frames);

  for( word frame_nr = 0; frame_nr < num_frames; frame_nr++ ) {
    for( byte row = 0; row < rainbow.num_rows; row++ ) {
      Serial.write( EEPROM.read(addr++) );
    }
    delay(1);
  }
}

void load_from_eeprom( word addr ) {
  rainbow.set_num_frames(EEPROM.read(addr++));
  for( word frame_nr = 0; frame_nr < rainbow.num_frames; frame_nr++ ) {
    for( byte row = 0; row < rainbow.num_rows; row++ ) {
      rainbow.set_frame_row(frame_nr, row, EEPROM.read(addr++));
    }
  }
}

rainbowduino.cpp

/*
 * Rainbowduino.h version 1.02 - A driver to run Seeedstudio 8x8 RBG LED Matrix
 * Copyright (c) 2009 Tobias Bielohlawek -> http://www.rngtng.com
 *
 */

// include this library's description file
#include "Rainbowduino.h"

// include core Wiring API
#include "WProgram.h"

// include description files for other libraries used (if any)
#include "pins_arduino.h"
#include "WConstants.h"

// Constructor /////////////////////////////////////////////////////////////////
// Function that handles the creation and setup of instances
Rainbowduino::Rainbowduino(byte set_num_frames) {
  DDRD = 0xff;
  DDRC = 0xff;
  DDRB = 0xff;
  PORTB = 0;
  PORTD = 0;
  num_frames = set_num_frames;
  num_rows = NUM_ROWS;
  max_num_frames = MAX_NUM_FRAMES;
  reset();
}


//=== Manipulating ==========================================================
void Rainbowduino::reset() {
  current_frame_nr = 0;
  current_row = 0;
  current_level = 0;
  current_frame_offset = 0;
}

void Rainbowduino::set_num_frames(byte new_num_frames)
{
  num_frames = min(new_num_frames, max_num_frames);
}

void Rainbowduino::set_frame(byte frame_nr, byte* data)
{
  if(frame_nr > num_frames) return;
  word offset = frame_nr * num_rows;
  for(byte row = 0; row < num_rows; row++) {
    frame_buffer[offset+row] = data[row];
  }
}

void Rainbowduino::set_frame_nr(byte frame_nr)
{
  if(frame_nr < num_frames) current_frame_nr = frame_nr;
}

void Rainbowduino::set_current_frame_row(byte row, byte data)
{
  set_frame_row(current_frame_nr, row, data);
}

void Rainbowduino::set_frame_row(byte frame_nr, byte row, byte data)
{
  if(frame_nr > num_frames) return;
  word offset = frame_nr * num_rows;
  frame_buffer[offset+row] = data;
}

void Rainbowduino::set_current_frame_line(byte x, byte red, byte green, byte blue)
{
  set_frame_line(current_frame_nr, x, red, green, blue);
}

void Rainbowduino::set_frame_line(byte frame_nr, byte x, byte red, byte green, byte blue)
{
  if(frame_nr > num_frames) return;
  word offset = frame_nr * num_rows;
  frame_buffer[offset+x]   = blue;
  frame_buffer[offset+x+1] = red;
  frame_buffer[offset+x+2] = green;
}

void Rainbowduino::set_current_frame_pixel(byte x, byte y, byte red, byte green, byte blue)
{
  set_frame_pixel(current_frame_nr, x, y, red, green, blue);
}

void Rainbowduino::set_frame_pixel(byte frame_nr, byte x, byte y, byte red, byte green, byte blue)
{
  if(frame_nr > num_frames) return;
  word offset = frame_nr * num_rows;
  frame_buffer[offset+x  ] = (blue  > 0) ? frame_buffer[offset+x]   | (1<<y) : frame_buffer[offset+x]   & ~(1<<y);
  frame_buffer[offset+x+1] = (red   > 0) ? frame_buffer[offset+x+1] | (1<<y) : frame_buffer[offset+x+1] & ~(1<<y);
  frame_buffer[offset+x+2] = (green > 0) ? frame_buffer[offset+x+1] | (1<<y) : frame_buffer[offset+x+2] & ~(1<<y);
}


void Rainbowduino::next_frame()
{
  current_frame_nr++;
  if(current_frame_nr >= num_frames) current_frame_nr = 0;
}

//=== Drawing ===========================================================
void Rainbowduino::draw(byte level) {
  off = current_frame_nr * num_rows + current_row;
  draw_row(current_row / 3, level, frame_buffer[off++], frame_buffer[off++], frame_buffer[off++]);
  if(current_row >= num_rows - 1) {
    current_row =  0;
    current_level = (current_level >= NUM_LEVEL - 1) ? 0 : current_level+1;    
  }
  else {
    current_row = current_row + 3;
  }
}

//--- colors to shift: blue, red,  green 
void Rainbowduino::draw_row(byte row, byte level, byte r, byte b, byte g) {
  disable_oe;
  enable_row(row);
  le_high;
  draw_color( (level > current_level) ? b : 0 );
  draw_color( (level > current_level) ? r : 0 );
  draw_color( (level > current_level) ? g : 0 );
  le_low;
  enable_oe;
}

void Rainbowduino::draw_color(byte c) {
  for(byte color = 0; color < 8; color++) {
    if(c > 127) {
      shift_data_1;
    }
    else {
      shift_data_0;
    }
    c = c << 1;
    clk_rising;
  }
}

//==============================================================
void Rainbowduino::enable_row(byte row) {   // open the scaning row
  //better? shift word value, take upper and lower part!?  
  if(row < 3) {
    PORTB  = (PINB & ~0x07) | 0x04 >> row;
    PORTD  = (PIND & ~0xF8);
  }
  else {
    PORTB  = (PINB & ~0x07);
    PORTD  = (PIND & ~0xF8) | 0x80 >> (row - 3);
  }
}

rainbowduino.h

/*
 * Rainbowduino.h version 1.02 - A driver to run Seeedstudio 8x8 RBG LED Matrix
 * Based on Rainbow.h by Seedstudio.com -> http://www.seeedstudio.com/depot/rainbowduino-led-driver-platform-plug-and-shine-p-371.html
 * Copyright (c) 2009 Tobias Bielohlawek -> http://www.rngtng.com
 *
 */

#ifndef RAINBOWDUINO_h
#define RAINBOWDUINO_h

// include types & constants of Wiring core API
#include <WProgram.h>

//=============================================
//MBI5168
#define SH_DIR   DDRC
#define SH_PORT   PORTC

#define SH_BIT_SDI   0x01
#define SH_BIT_CLK   0x02

#define SH_BIT_LE    0x04
#define SH_BIT_OE    0x08
//============================================
#define clk_rising  {SH_PORT &= ~SH_BIT_CLK; SH_PORT |= SH_BIT_CLK; }
#define le_high     {SH_PORT |= SH_BIT_LE; }
#define le_low      {SH_PORT &= ~SH_BIT_LE; }
#define enable_oe   {SH_PORT &= ~SH_BIT_OE; }
#define disable_oe  {SH_PORT |= SH_BIT_OE; }

#define shift_data_1     {SH_PORT |= SH_BIT_SDI;}
#define shift_data_0     {SH_PORT &= ~SH_BIT_SDI;}

#define NUM_LINES 8
#define NUM_ROWS 24 // 3 BYTES per ROW  x 8 Lines
#define MAX_NUM_FRAMES 10 // 3 BYTES  per ROW

#define NUM_LEVEL 16 

class Rainbowduino {

public:
  byte num_frames;
  byte max_num_frames;
  byte num_rows;

  byte frame_buffer[24*MAX_NUM_FRAMES]; // [FRAME_BUFFER_SIZE]; //size of EEPROM -> to read faster??

  Rainbowduino(byte set_num_frames = 1);
  void reset();
  void set_num_frames(byte new_num_frames);
  void set_frame(byte frame_nr, byte* data);
  void set_frame_nr(byte frame_nr);
  void set_frame_row(byte frame_nr, byte row, byte data);
  void set_current_frame_row(byte row, byte data);
 
  //to set all 3 colors of each line
  void set_frame_line(byte frame_nr, byte x, byte red, byte green, byte blue);
  void set_current_frame_line(byte x, byte red, byte green, byte blue);

  //to set all 3 colors of each pixel
  void set_frame_pixel(byte frame_nr, byte x, byte y, byte red, byte green, byte blue);
  void set_current_frame_pixel(byte x, byte y, byte red, byte green, byte blue);

  void next_frame();
  void draw(byte level = 12);

private:
  byte current_frame_nr;
  word current_frame_offset;
  word off;  //buffer offset
  volatile byte current_row;
  volatile byte current_level;

  void draw_row(byte row, byte level, byte r, byte b, byte g);
  void draw_color(byte c);
  void enable_row(byte row);
};

#endif //RAINBOWDUINO.h

I had no problems compiling your sketch for the Uno.

just tried on arduino 1.0 and still doesnt work, tried older versions either and get the same result ):

It compiled OK for me using IDE 1.0 once I changed WProgram.h to Arduino.h and got rid of the include for WConstants.h.

Binary sketch size: 3582 bytes (of a 32256 byte maximum)

Are you sure you got that first line?

/*

yes i have the /* for the comments, i tried compiling on arduino 1.0 again and ammended the .h includes but i still get

Rainbowduino.cpp:0: error, expected constructor, destructor or type conversion before '/' token

Try this... • Open Rainbowduino.cpp • Select all then delete • Select the Rainbowduino.cpp source code from your post above • Paste into Rainbowduino.cpp • Save • Try again

[quote author=Coding Badly link=topic=105770.msg793629#msg793629 date=1336985271]

Try this... • Open Rainbowduino.cpp • Select all then delete • Select the Rainbowduino.cpp source code from your post above • Paste into Rainbowduino.cpp • Save • Try again

[/quote]

when i do that without amending header changes it throws me all these errors., unless i ammend the header changes which then leaves me with the Rainbowduino.cpp:0: error, expected constructor, destructor or type conversion before '/' token

when i do that

Using Arduino 0022?

[quote author=Coding Badly link=topic=105770.msg793644#msg793644 date=1336986480]

when i do that

Using Arduino 0022?

[/quote]

thats on arduino 1.0,

when i use arduino 0022, it just auto gives the "Rainbowduino.cpp:0: error, expected constructor, destructor or type conversion before '/' token" and doesnt compile

i tried 0023, 0021 and 0020 and they all throw back

Rainbowduino.cpp:0: error, expected constructor, destructor or type conversion before '/' token

might it have something to do with windows 7?

Post your exact code as an attachment. This wouldn't be the first time someone has left out the first (or last) line of code they found on a web site.

attached all necessary files

firmware.pde (5.21 KB)

RCodes.h (1.7 KB)

Rainbowduino.cpp (4.29 KB)

Rainbowduino.h (2.23 KB)

Disable all real-time anti-virus processes.

[quote author=The Clever Monkey link=topic=105770.msg793787#msg793787 date=1336997466]
Disable all real-time anti-virus processes.
[/quote].
I do not have any kind of anti virus on my computer

I compiled those 4 files without error after changing wprogram.h to arduino.h Did you have gcc previously installed or is arduino using the copy it had in the download?

I would recommend removing all versions of arduino IDE ( and driver installs ) and start fresh with 1.0

pYro_65:
I compiled those 4 files without error after changing wprogram.h to arduino.h
Did you have gcc previously installed or is arduino using the copy it had in the download?

I would recommend removing all versions of arduino IDE ( and driver installs ) and start fresh with 1.0

ive never had a previous installation of GCC, so id say id be using the one that came with the IDE, i did copy my libraries to the arduino 1.0 folder when i tried first time around, the only sketch i got to work was an old rainbowduino 1.05 but i have no idea how to use that firmware, ill try a fresh slate and see how that goes and report back.

just tried a cleanslate on arduino 1.0, re-installed the UNO driver and all, opened the latest MTXcontrol firmware sketch, ammended the headers, and got thrown a massive pile of errors.

though an older version of the mtxcontrol firmware compiled fine, but, the only problem is the software on my PC to control it will not interact with it because it's using older firmware, so i need to figure out how to fix the latest firmware

On Arduino 1.0, after making the changes I mentioned about the header files, I get this:

Binary sketch size: 3768 bytes (of a 32256 byte maximum)