It's possible to modify Arduino library wiring.c

I added this function

void reset_millis()
{
old_SREG = SREG;
cli();
timer0_millis=0;
timer0_overflow_count=0;
SREG = old_SREG;
}

in C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\wiring.c

and the prototype same directory
( void reset_millis(void); ) in Arduino.h

when I compile I have the following error message

reset_millis' was not declared in this scope

Can anybody help me

I know modifying a original librairy it's not a good way !
I just want to know why it does not work
Thk

(deleted)

I added this function

void reset_millis()

Which begs the question "Why?"

After all this time, if such a function didn't exist, don't you think someone else would have thought of creating it?

Please remember to use code tags when posting code.

Well, the example code seems to turn off all interrupts and never turns them back on. Maybe that's the intent? Stop that pesky millis() from ever counting again.

It's also highly non-portable and will only work on the AVR Arduinos.

AWOL:
After all this time, if such a function didn't exist, don't you think someone else would have thought of creating it?

I suspect you meant to say
After all this time, if such a function didn't exist and had any value, don't you think someone else would have thought of creating it?

I can't think of any reason why it might be necessary to reset the value of miilis() and I suspect that code that assumes it is not reset would not not work properly if it is reset.

...R

Forget this function.

My question is :

Is it possible to add a function or modify wiring.c ? And not have this error message:

xxxxx was not declared in this scope

Yes, of course it is.

(deleted)

spycatcher2k:
You also need to modify Arduino.h

they did:

Harrix:
and the prototype same directory
( void reset_millis(void); ) in Arduino.h

MorganS:
It's also highly non-portable and will only work on the AVR Arduinos.

Since they are adding it to the Arduino AVR Boards core library that's not a problem as it can only ever be used on AVR Arduinos. Not that I'm defending the value of this function.

Now to answer the question. You haven't provided enough information to give a specific answer but I can think of two reasons:

  • Arduino sketches are C++. wiring.c is C. That means you need to wrap the declaration of your function in extern "C" {}. There is a section of Arduino.h that is for C function declarations and a section for c++ function declarations. If you didn't put your function in the area wrapped in extern "C" {} you will get just this error.
  • If you have updated your Arduino AVR Boards version via Boards Manager or are not compiling for a board that uses the Arduino AVR Boards core library then the files you edited will not be used and you will get the error.