"class was not declared in this scope" I could swear it was.

I have a file,

that includes another file,
https://github.com/i-make-robots/Delta-Robot/tree/master/arduino/ik/Vector3.ino
and yet when I compile on OSX Arduino 1.0.1 I get...

ik:3: error: 'Vector3' was not declared in this scope
ik:40: error: 'Vector3' does not name a type
ik:41: error: 'Vector3' does not name a type
ik:42: error: 'Vector3' does not name a type
ik:43: error: 'Vector3' does not name a type
ik:44: error: 'Vector3' does not name a type
ik.cpp: In function 'void setup_robot()':
ik:91: error: 'Vector3' was not declared in this scope
ik:91: error: expected `;' before 'temp'
ik:98: error: 'class Joint' has no member named 'pos'
ik:102: error: 'class Joint' has no member named 'pos'
ik:106: error: 'n' was not declared in this scope
ik:106: error: 'class Joint' has no member named 'pos'
ik:108: error: 'temp' was not declared in this scope
ik:108: error: 'class Joint' has no member named 'pos'
ik:109: error: 'class Joint' has no member named 'pos'
ik:112: error: 'class Joint' has no member named 'pos'
ik:114: error: 'class Joint' has no member named 'relative'
ik:114: error: 'class Joint' has no member named 'pos'
ik:115: error: 'class Joint' has no member named 'relative'
ik:115: error: 'class Joint' has no member named 'pos'
ik:116: error: 'class Joint' has no member named 'relative'
ik:119: error: 'class Joint' has no member named 'pos'
ik.cpp: At global scope:
ik:151: error: redefinition of 'char outOfBounds'
ik:3: error: 'char outOfBounds' previously defined here
ik:151: error: 'Vector3' was not declared in this scope

Please: what am I doing wrong and how do I fix it?

Thank you!

I'd help you out, but I don't see anything useful at either of those links. Use the Additional Options link below to attach the code.

Here you go.

ik.ino (12.9 KB)

Here is vector3.h

Vector3.h (6.82 KB)

Are you certain that is the way those files are supposed to be compiled? It looks like you must open the first file, then add the second file.

Open the file ik.ino with your IDE. Then select "Sketch/Add file". Find and add Vector3.ino. Compile.

Is that what you did?

The moment I open the first file it automatically opens the second, same as in the Marlin sourcecode.
I tried it your way... no difference.

Why is Vector3.h, being used with a .ino file, including WProgram.h? That does not exist after 1.0.

It seems I've fixed the problem. I checked it into Github if anyone wants to see. A few of the operators had to be removed and I cut out some other stuff just to be on the lean side.

Thanks for the help!

I don't think your sketch can "include" another .ino file.

It normally has to include .h files

#include will grab any text file, some things that get included aren't valid c or c++ so putting it in a .c, .h, or .cpp would be misleading.

pYro_65:
#include will grab any text file, some things that get included aren't valid c or c++ so putting it in a .c, .h, or .cpp would be misleading.

You mean if you were doing

char* str = 
#include "stringsource"
;

stringsource:

"Hello this is a string"

How would you do that without quotation marks in the included file?

That wasn't my exactly my intention, by text file I meant a non binary file, however, I'll post an example from some code I wrote a while ago to help me do a platform independent low level IO system.

This is part of the AVR implementation, it dynamically loads a particular file based on the chipset, that file is used to create an array of pins for port mapping.

#if defined(__AVR_ATmega168__) ||defined(__AVR_ATmega168P__) ||defined(__AVR_ATmega328P__)
	#define CHIPSET ATmega_168_168P_328P 
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
	#define CHIPSET ATmega_1280_2560 
#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
	#define CHIPSET ATmega_644_644P_1284P 
#elif defined(__AVR_ATmega32U4__)
	#ifdef CORE_TEENSY 
		#define CHIPSET ATmega_32U4_A 
	#else
		#define CHIPSET ATmega_32U4_B 
	#endif
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
	#define CHIPSET AT90USB_646_1286 
#endif
#define _PIN( port, bit )      {&DDR##port, &PIN##port, &PORT##port, bit},

const static pin_map_t pinMap[] = {
#include 	INCLUDE_FILE_3(HARDWARE_PREFIX,GENX_PLATFORM,MAKE_DIR(CHIPSET),.pins)
};
#undef CHIPSET
#undef _PIN

and this is the pins file for the 328

_PIN( D, 0 )
_PIN( D, 1 )
_PIN( D, 2 )
_PIN( D, 3 )
_PIN( D, 4 )
_PIN( D, 5 )
_PIN( D, 6 )
_PIN( D, 7 )

_PIN( B, 0 )
_PIN( B, 1 )
_PIN( B, 2 )
_PIN( B, 3 )
_PIN( B, 4 )
_PIN( B, 5 )

_PIN( C, 0 )
_PIN( C, 1 )
_PIN( C, 2 )
_PIN( C, 3 )
_PIN( C, 4 )
_PIN( C, 5 )

This list is laid out for the Uno pin layout, very easy to re-order for other designs.