[RESOLVED] Error: expected constructor, destructor or type conversion???

Hi guys, I’m trying to create the basic library (for learning purposes) below, and I’m getting the following errors:


[b]expected constructor, destructor, or type conversion before '(' token[/b]

In file included from ReadMPU9150.ino:2:
/Users/kschembri/Documents/Arduino/libraries/MPU9150/MPU9150.h:9: error: expected unqualified-id before 'int'
/Users/kschembri/Documents/Arduino/libraries/MPU9150/MPU9150.h:9: error: expected `)' before 'int'
/Users/kschembri/Documents/Arduino/libraries/MPU9150/MPU9150.h:7: error: an anonymous struct cannot have function members
/Users/kschembri/Documents/Arduino/libraries/MPU9150/MPU9150.h:14: error: abstract declarator '<anonymous class>' used as declaration
ReadMPU9150:5: error: expected constructor, destructor, or type conversion before '(' token
ReadMPU9150.ino: In function 'void setup()':
ReadMPU9150:38: error: 'MPU' was not declared in this scope

The header

#ifndef MPU9150
#define MPU9150

#include <Arduino.h>

class MPU9150 
		MPU9150(int address);
		int write(int address, int data);

		int MPU9150_ADDRESS;


The contents

#include "Arduino.h"
#include "MPU9150.h"

MPU9150::MPU9150(int address)
	MPU9150_ADDRESS = address;

int MPU9150::write(int address, int data)
	return 1;

The sketch

#include "Wire.h"
#include "MPU9150.h"

// Define the MPU9150 object
MPU9150 MPU(0x68);

// Define the locations of various MPU addresses
#define MPU9150_PWR_MGMT_1         0x6B
void setup()
  // Clear the 'sleep' bit to start the sensor.
  MPU.write(MPU9150_PWR_MGMT_1, 0);

void loop()

I would appreciate any guidance… thank you!

Well, you would be asking for trouble with using the #ifndef thing at the top of the file, with the same name as your class. Usually, you would have some unique name for that, like #ifndef MPU9150_H

You are also asking for trouble, or at least confusion, or maybe obfuscation, by not distinguishing anywhere between the I2C device address, and the device's internal register address.

Oh I see, okay that makes sense. Thanks!