Skip to content

Placing interrupt function after setup() -> "error: too many decimal points in number" #7123

@MagnusThome

Description

@MagnusThome

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: Wemos D1 mini
  • Core Version: 2.6.3
  • Development Env: Arduino IDE
  • Operating System: Windows

Settings in IDE

Untitled

Problem Description

If the interrupt function is declared or defined before setup() all works as it should. But if the interrupt function is defined further down in the code (and no declaration at the top) it will not compile and I get this error message:

est2:15:61: error: too many decimal points in number
 void ICACHE_RAM_ATTR irqfunc () {
                                                             ^
test2:15:42: error: request for member 'iram' in '""', which is of non-class type 'const char [1]'
 void ICACHE_RAM_ATTR irqfunc () {
                                          ^
test2:15:6: error: section attribute not allowed for 'void irqfunc()'
 void ICACHE_RAM_ATTR irqfunc () {
      ^
exit status 1
too many decimal points in number

I can't find any info on this, shouldn't the compile error message rather say function xxx not declared in this scope? It really isn't a very helpful error message, especially since it's quite common in the Arduino environment not to declare functions and just define them further down in the code?

DOES NOT COMPILE

#define GPIO 5
volatile bool irqdetected = false;

void setup(void) {
  Serial.begin(115200);   
  pinMode(GPIO, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(GPIO), irqfunc, FALLING);
} 
void loop(void) {
  if (irqdetected) {
    Serial.println("irq");
    irqdetected = false;
  }
}
void ICACHE_RAM_ATTR irqfunc () {
  irqdetected = true;
}

COMPILES OK

#define GPIO 5
volatile bool irqdetected = false;

void ICACHE_RAM_ATTR irqfunc () {
  irqdetected = true;
}
void setup(void) {
  Serial.begin(115200);   
  pinMode(GPIO, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(GPIO), irqfunc, FALLING);
} 
void loop(void) {
  if (irqdetected) {
    Serial.println("irq");
    irqdetected = false;
  }
}

COMPILES OK

#define GPIO 5
volatile bool irqdetected = false;

void ICACHE_RAM_ATTR irqfunc ();

void setup(void) {
  Serial.begin(115200);   
  pinMode(GPIO, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(GPIO), irqfunc, FALLING);
} 
void loop(void) {
  if (irqdetected) {
    Serial.println("irq");
    irqdetected = false;
  }
}
void ICACHE_RAM_ATTR irqfunc () {
  irqdetected = true;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions