Compiler error: 's' does not name a type.

Hey folks, I'm new to this forum and in fact new to Arduino all together. Plus the fact that I've not coded in 15 yrs, this error is eluding me. I failed with Google and hope to get some advise here.

Using Arduino 1.6.4 on Mac, this is the bare minimum code to illustrate my issue. Image of IDE attached..

Thanks... Hose

.../Arduino/Libraries/SMP/SMP.h:

#ifndef SMP_h
#define SMP_h

#include <Arduino.h>

class SMP {

	public:
		
		SMP();
		
		void say(byte word);
		
	private:
		
};

#endif

.../Arduino/Libraries/SMP/SMP.cpp:

#include <Arduino.h>
#include "SMP.h"

// Constructor
SMP::SMP() {
	
{
	
void SMP::say(byte word) {
	
	Serial.println(word);
}

Hello and welcome

That should be

SMP s;

As any variable declaration, the type must be before the name :wink:

I had tried that before and it get's this error...

Test.ino: In function 'void loop()':
Test:12: error: invalid conversion from 'const char*' to 'byte {aka unsigned char}' [-fpermissive]
In file included from Test.ino:1:0:
/Users/hose/Development/Arduino/libraries/SMP/SMP.h:12:8: error:   initializing argument 1 of 'void SMP::say(byte)' [-fpermissive]
   void say(byte word);
        ^
invalid conversion from 'const char*' to 'byte {aka unsigned char}' [-fpermissive]

Can you please change this:

#include <Arduino.h>
#include "SMP.h"

// Constructor
SMP::SMP() {
	
{
	
void SMP::say(byte word) {
	
	Serial.println(word);
}

to this:

#include <Arduino.h>
#include "SMP.h"

// Constructor
SMP::SMP() {
	
}	
void SMP::say(byte word) {
	
	Serial.println(word);
}

and try again?

Good catch on that constructor curly, but same error in the compilation...

OK, so post what you've got now

It's the same as my original post, with lui's correction on my curly brackets in SMP.cpp

SMP.h

#ifndef SMP_h
#define SMP_h

#include <Arduino.h>

class SMP {

	public:
		
		SMP();
		
		void say(byte word);
		
	private:
		
};

#endif

SMP.cpp

#include <Arduino.h>
#include "SMP.h"

// Constructor
SMP::SMP() {
	
}
	
void SMP::say(byte word) {
	
	Serial.println(word);
}

Test.ino

#include "SMP.h"

s SMP;

void setup()
{
Serial.begin(9600);
}

void loop()
{
s.say("Hello");
delay(2000);
}
SMP s;

What you have is like writing var int;

Change the SMP.h to:

#ifndef SMP_h
#define SMP_h

#include <Arduino.h>

class SMP {

	public:
		
		SMP();
		
		void say(char *word);
		
	private:
		
};

#endif

change SMP.cpp to:

#include <Arduino.h>
#include "SMP.h"

// Constructor
SMP::SMP() {
	
}
	
void SMP::say(char *word) {
	
	Serial.println(word);
}

The code:

#include "SMP.h"

SMP s;

void setup()
{
Serial.begin(9600);
}

void loop()
{
s.say("Hello");
delay(2000);
}

will work.

Thank you all, I realized what I was doing and changed the data type in s.say from "Hello" to 1. Works fine as it should.

Thanks to all that responded....