Does not name a type in ino file

Somebody put me out of my misery. What is wrong with this:

class TeddyBear {
};

TeddyBear *InitialiseMicros( void ) {
	return (TeddyBear*)0;
}

void setup() {
}

void loop() {
}

This is in a file called test.ino, compiling from the Web IDE. I get the following:

In file included from ../inc/spark_wiring.h:29:0,
  from ../inc/application.h:29,
  from test.cpp:2:
 ../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
  #warning "Defaulting to Release Build"
  ^
 test.cpp:3:1: error: 'TeddyBear' does not name a type
  TeddyBear *InitialiseMicros( void );
  ^
 make: *** [test.o] Error 1

What is going on here? TeddyBear does name a type! I’m thinking I have forgotten something Arduinoish because the code doesn’t compile in the Arduino environment either. However, stick it into Visual Studio 2012, add an empty main method and it compiles fine.
What am I doing wrong?

I think you are being bitten by the Arduino preprocessor that tries to handle function prototypes for you.

Try adding this to the top of your file:

#pragma SPARK_NO_PREPROCESSOR
#include "application.h"
2 Likes

Fantastic. That works. Thanks very much. That sort of help from a pre-processor I can do without.

1 Like

Ack, sorry about that! Silly pre-processor. :frowning:

Thanks,
David

2 Likes

I’m getting a the same message with ‘GET’ does not name a type when I try to flash the temperature ino. example. I have included both

#pragma SPARK_NO_PREPROCESSOR
#include "application.h"

but I still have the problem.
I would appreciate any help.

Hi @popshop

It sounds like you might have accidentally cut-and-pasted too much code from the example. The GET command is an HTTP command that you might do in web browser, not in the core firmware. If you post your code we can clear this up.

1 Like

I’m using the example at http://docs.spark.io/examples/ “Measuring the temperature” with no changes, that is why I am surprised it doesn’t work. I am using my device’s ID and access token. I am new at this so I am probably missing something obvious.

Hi @popshop

You definitely cut and paste too far. The end of the core firmware is the curly brace at the bottom of the first “box”.

The next “box” has web commands that let you access the cloud. A good example are the curl commands – curl is a command line tool on pc/Linux/Mac that does the kind of web requests you can do in a browser.

1 Like