Go Down

Topic: Stray characters error (Read 4564 times) previous topic - next topic

ajofscott

I'm getting the following compiler complaints but the referenced strays cannot be found. Arduino version 1.0.
Project files accompany post.

Code: [Select]
C:\arduino-1.0\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=100 -IC:\arduino-1.0\hardware\arduino\cores\arduino -IC:\arduino-1.0\hardware\arduino\variants\standard -IC:\arduino-1.0\libraries\FastADC C:\Users\AARONJ~1.SCO\AppData\Local\Temp\build5886924818106296315.tmp\FastDAC_ino.cpp -oC:\Users\AARONJ~1.SCO\AppData\Local\Temp\build5886924818106296315.tmp\FastDAC_ino.cpp.o
In file included from FastDAC_ino.cpp:1:
C:\arduino-1.0\libraries\FastADC/FastADC.h:1: error: stray '\357' in program
C:\arduino-1.0\libraries\FastADC/FastADC.h:1: error: stray '\273' in program
C:\arduino-1.0\libraries\FastADC/FastADC.h:1: error: stray '\277' in progra

Morris Dovey

Just for grins, try opening FastDAC_ino.ino in your favorite program editor and removing everything after the final brace...
There's always a better way!

PaulS

I don't get those errors, but I do get lots of others. Your cpp is missing plenty of includes.

ajofscott

Deleting the last 3 lines in FastADC_ino had no effect, and in respect to includes here is the post preprocess file:
Code: [Select]
#include "FastADC.h"
#include "Arduino.h"
void setup();
void loop();
FastADC Conv1;
void setup()
  {
    Serial.begin(9600);
    Conv1.Resolution(8);
    Conv1.Comparator = 0;
  }
void loop()
  {

    if (!Conv1.InProgress())
      {
        Serial.println(Conv1.Output());
        Serial.println(Conv1.Resolution());
        Serial.println(Conv1.InProgress());
        Serial.println(Conv1.ApproxMask());
        Conv1.Start();
      }
     Serial.println(Conv1.InProgress());
       
   }



So I don't see anything not included that should be.

ajofscott

I found a missing closing parenthesis in FastADC.cpp @ line 81 but it didn't resolve the strays error, the compiler didn't get that far apparently.

ajofscott

The issue was my code editor saved the file in UTF8 format, not ANSI.

ajofscott

It is a a mu point in the end. It would seem I can't use 'attachInterrupt()' from within a class.

PaulS

Quote
It would seem I can't use 'attachInterrupt()' from within a class.

Sure, you can. You just can't attach a non-static method. How would the Arduino know which instance to call the handler for?

ajofscott

So how do I make one function shared uniquely to all instances of the class?

PaulS

Quote
So how do I make one function shared uniquely to all instances of the class?

Declare it static.

ajofscott

I see I will have to handle the interrupt externally and ping the function from the ISR or make a copy of the attachInterrupt function and make it local to the class. The reasoning for the class was not for multiple instances, but for ease of use...or so I thought. The easiest for me is to just call CompareShift from the main body.

PaulS

Quote
The reasoning for the class was not for multiple instances, but for ease of use..

Perhaps, but the compiler has no way of knowing that you will only make one instance of the class.

There are ways of making a copy of the this pointer in the constructor, and then using that copy in the static method to access the non-static members of the class IF you do only create one instance.

I do that all the time at work, when the class is a dialog class, and I want to use a progress bar dialog class. The progress bar class requires a static method, just like attachInterrupt, for very similar reasons. Each class that uses the progress bar class is a singleton (only one instance at a time), so I register a static method for the progress bar class to call, and in that static method I call the real class member function using the static copy of the pointer to this that the constructor of the singleton made.

Go Up