1

even if i dont use this function it always uses 4 bytes of ram if the function is implemented in the cpp (because of the attachInterrupt()). If i make it inline in the .h it doesnt compile anything

.h
// attach the interrupt function
void IRLbegin(const uint8_t interrupt);

.cpp
void IRLbegin(const uint8_t interrupt){
// attach the function that decodes the signals
attachInterrupt(interrupt, IRLinterrupt, CHANGE);
}

What can i do against that? writing everything in the .h isnt good coding style i think. I cannot change optimization settings due to Arduino environment.

Alan Stokes
  • 18,815
  • 3
  • 45
  • 64
  • 2
    Related to [do-unused-functions-get-optimized-out](http://stackoverflow.com/questions/6215782/do-unused-functions-get-optimized-out). – Jarod42 Sep 14 '14 at 13:41
  • Clarify your question to describe what you are looking at that makes you think RAM use is increasing. What you show in your question would increase ROM or flash. Also do you truly care about the compiler output? Or is your question about the final program produced by the linker. The two are very different questions. – jdr5ca Sep 15 '14 at 05:28
  • I am using Arduino environment and this shows how much flash and ram is used after compiling. And it seems that when i add the attachInterrupt function in the begin() function without using it takes 4 bytes of ram. So the compiler/linker somehow puts this function in my code. if the begin() function is inline in the .h it wont use 4 bytes of ram. –  Sep 16 '14 at 09:20

1 Answers1

0

A function that simply calls another function is fine inlined in a header. Try the 1.5.8 version of the IDE as it has a newer compiler and will generally inline small functions in a .CPP I have found.

Chris A
  • 1,475
  • 3
  • 18
  • 22
  • Hi! Doesnt 1.5.7 introduced this compiler? I was developing with 1.5.7 but havent tested the new 1.5.8. So is there any difference? As far as i know the compiler stays the same. –  Oct 09 '14 at 15:45
  • Yes, 1.5.7 was upgraded to GCC 4.8.2, however 1.5.8 is available now. All previous versions from 1.5.6r2 and below use GCC 4.3.2, the same as the entire 1.0.x series. – Chris A Oct 10 '14 at 02:49
  • So sadly that didnt help :( –  Oct 11 '14 at 09:20
  • if you can use avr-nm you can see what uses the ram. if not post your .elf file for me to check, or i can try reproduce it when home! – Chris A Oct 12 '14 at 01:57