Skip to main content
added 368 characters in body
Source Link
Code Gorilla
  • 5.7k
  • 1
  • 17
  • 31

Have you tried placing the H file in the same folder as you main cpp file. This should prove beyond all doubt that there is nothing wrong with the code (I can't see anything wrong).

I suspect its a path issue. You need to check that Eclipse is setup up properly to source the libraries from you custom location. Also it needs to be passing this location on to the compiler. I don't know how to do that in Eclipse but Google should point you in the right direction. Try this http://forum.arduino.cc/index.php?topic=39972.0 ?

Also you might find it easier to specify the include files in the order system, 3rd party libraries, local libraries and then local include files. This means that duplicate definition faults are reported against the files nearest to the ones you have written. If you define time_t using your ordering the fault will be reported against <time.h> rather than your header file.

Also a using namespace foo statement removes the benefits that namespaces provide, so its best not to do it.

EDIT Doh - I should have spotted this sooner. Template classes have to have the functions inline not in a CPP file. This is because the CPP file can't change what T is at compile time, but because the H file is included in the file it is used in when it is preprocessed the object represented by T can change. Basically inline your functions and it will work.

Have you tried placing the H file in the same folder as you main cpp file. This should prove beyond all doubt that there is nothing wrong with the code (I can't see anything wrong).

I suspect its a path issue. You need to check that Eclipse is setup up properly to source the libraries from you custom location. Also it needs to be passing this location on to the compiler. I don't know how to do that in Eclipse but Google should point you in the right direction. Try this http://forum.arduino.cc/index.php?topic=39972.0 ?

Also you might find it easier to specify the include files in the order system, 3rd party libraries, local libraries and then local include files. This means that duplicate definition faults are reported against the files nearest to the ones you have written. If you define time_t using your ordering the fault will be reported against <time.h> rather than your header file.

Also a using namespace foo statement removes the benefits that namespaces provide, so its best not to do it.

Have you tried placing the H file in the same folder as you main cpp file. This should prove beyond all doubt that there is nothing wrong with the code (I can't see anything wrong).

I suspect its a path issue. You need to check that Eclipse is setup up properly to source the libraries from you custom location. Also it needs to be passing this location on to the compiler. I don't know how to do that in Eclipse but Google should point you in the right direction. Try this http://forum.arduino.cc/index.php?topic=39972.0 ?

Also you might find it easier to specify the include files in the order system, 3rd party libraries, local libraries and then local include files. This means that duplicate definition faults are reported against the files nearest to the ones you have written. If you define time_t using your ordering the fault will be reported against <time.h> rather than your header file.

Also a using namespace foo statement removes the benefits that namespaces provide, so its best not to do it.

EDIT Doh - I should have spotted this sooner. Template classes have to have the functions inline not in a CPP file. This is because the CPP file can't change what T is at compile time, but because the H file is included in the file it is used in when it is preprocessed the object represented by T can change. Basically inline your functions and it will work.

Source Link
Code Gorilla
  • 5.7k
  • 1
  • 17
  • 31

Have you tried placing the H file in the same folder as you main cpp file. This should prove beyond all doubt that there is nothing wrong with the code (I can't see anything wrong).

I suspect its a path issue. You need to check that Eclipse is setup up properly to source the libraries from you custom location. Also it needs to be passing this location on to the compiler. I don't know how to do that in Eclipse but Google should point you in the right direction. Try this http://forum.arduino.cc/index.php?topic=39972.0 ?

Also you might find it easier to specify the include files in the order system, 3rd party libraries, local libraries and then local include files. This means that duplicate definition faults are reported against the files nearest to the ones you have written. If you define time_t using your ordering the fault will be reported against <time.h> rather than your header file.

Also a using namespace foo statement removes the benefits that namespaces provide, so its best not to do it.