Go Down

Topic: [SOLVED] "xxxxxx does not name a type" error message (Read 94059 times) previous topic - next topic

thomasow

Mar 23, 2013, 04:35 am Last Edit: Mar 23, 2013, 09:31 pm by thomasow Reason: 1
Hello.  I am having difficulty trying to use the ByteBuffer lib.  http://siggiorn.com/arduino-circular-byte-buffer/.  I am sure it is something simple, and am hoping you can give me a hint...

I downloaded the .zip file, opened it and copied all the contained files into a subdirectoy named "ArduinoByteBuffer" in the ...\MyDocuments\Arduino\libraries  directory.    (WinXP, Arduino 1.0.3)

I then try to compile the example sketch, but get the following error:  "ByteBufferExample:8: error: 'ByteBuffer' does not name a type"

Here is the sample code (included with the Lib):
Code: [Select]

#include <ByteBuffer.h>

/*
  Silly program that emulates buffered processing
  using a circular bytebuffer
*/

ByteBuffer buffer;

void setup()
{
  // Initialize the buffer with a capacity for 256 bytes
  buffer.init(256);

  // Init serial just to debug
  Serial.begin(9600);
}

int cnt = 0;
void loop() {
  cnt++;

  // Every 100th update
  if( cnt%100 == 0 ){
    buffer.clear();
    buffer.put(200); // Put one byte at end
    buffer.putInt(2000); // Put one int at end
    buffer.putLong(20000); // Put one long at end
    buffer.putFloatInFront(200000); // Put one float at beginning
  }

  // Every 100th update (20 updates offset)
  if( (cnt+20)%100 == 0 ){
    Serial.println("Received following bytes");
      while( buffer.getSize() > 0 )
        Serial.println(buffer.get(), DEC);
    Serial.println("");
  }
}




And here is the entire list of error messages I get:

ByteBufferExample:8: error: 'ByteBuffer' does not name a type
ByteBufferExample.pde: In function 'void setup()':
ByteBufferExample:13: error: 'buffer' was not declared in this scope
ByteBufferExample.pde: In function 'void loop()':
ByteBufferExample:25: error: 'buffer' was not declared in this scope
ByteBufferExample:35: error: 'buffer' was not declared in this scope


I tried changing #include <ByteBuffer.h>  to   #include "ByteBuffer.h", that did not help.  I also tried moving the ByteBuffer lib into the c:\program\arduino....  directory, again did not help.

  I am sure this is something simple, and would appreciate any pointers.


spatula

The library has a nonstandard (for 1.0.3) directory structure: you should move the .cpp and .h files in ...\Arduino\libraries\ArduinoByteBuffer.

thomasow

#2
Mar 23, 2013, 01:52 pm Last Edit: Mar 23, 2013, 03:58 pm by thomasow Reason: 1
That fixed it!

I noticed that in addition to moving the two files up I needed to also remove all the 'extra' directory structures.  Just leaving the two files and the example sub directory.

Thank you.



thomasow

#4
Sep 18, 2013, 05:04 pm Last Edit: Dec 28, 2013, 07:30 pm by thomasow Reason: 1

Move the files to...?


Hello, sorry - I can see the answer above is not really that clear :-)

So, as supplied, the ArduinoByteBuffer.zip file had a complex set of sub-directories, and the two files ByteBuffer.ccp and ByteBuffer.h were located one level down in: \ArduinoByteBuffers\ByteBuffer\

When I 'installed' the library, it went into the directory: 
  C:\Documents and Settings\Al\My Documents\Arduino\libraries\ArduinoByteBuffers\ByteBuffer\ByteBuffer.ccp
   C:\Documents and Settings\Al\My Documents\Arduino\libraries\ArduinoByteBuffers\ByteBuffer\ByteBuffer.h

To solve the problem I moved them up a level to:
   C:\Documents and Settings\Al\My Documents\Arduino\libraries\ArduinoByteBuffers\ByteBuffer.ccp
   C:\Documents and Settings\Al\My Documents\Arduino\libraries\ArduinoByteBuffers\ByteBuffer.h

That seemed to be the key - moving the two files (*.ccp and *.h) out of the subdirectory.

I also noted there was a LOT of extra junk contained in the .zip file, best as I can tell some extra stuff associated with an Apply system?  Things like:  \ArduinoByteBuffers\ByteBuffer\.snv\prop-base\   There were a lot of them, I removed all the extra sub-directories except the one containing the examples.  IIRC, I needed to do this cleanup as well as the extra stuff was causing errors as well....


So, bottom line:  Moved the .CCP and .H file out of sub-directories, and removed all the 'extra' sub-directories outside of the examples one.   That is what I had to do to get it to work.   Hope this is a bit more clear and helps anyone who also gets this type of error!

-al-


I moved these two files from

fatterdanner


guygo

Just a heads up to anyone seeing this error, is sure that they have all the right libraries in the right places, and is pretty sure their class syntax is copacetic:
I was getting this error after writing a very simple LED class (of course it was late at night), and couldn't figure out why.  Everything looked good, yet any reference to the class type borked.  The next day, after more careful observation, I found that I had my class header guard statement written as:

#ifdef MyClass
#define MyClass
.
.
.
#endif

Once I changed the "#ifdef" to #ifndef", all worked as it should.  D'oh!  All that angst over one little "n".
Anyway, it's something to check, because if you don't have that "n" in there, the class header never gets processed by the compiler, so your class method definitions make no sense to it, so at the first mention of one your get the "... does not name a type" error.

Oh them typos.  Rock on, folks!

Go Up