Pages: [1]   Go Down
Author Topic: Memory and unused functions in a library  (Read 219 times)
0 Members and 1 Guest are viewing this topic.
West palm beach, FL
Offline Offline
Sr. Member
****
Karma: 1
Posts: 325
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

well not exactly a library just another c file and header file , ive yet to learn about libraries and linking so for now i am only writing things in separate c and h files
but i wonder if i write a generic c file with multiple functions for doing a lot of tasks but  i only use some of them in my main c file do the unused ones take up memory?


 
Logged

I could print the Arduino logo on a box of cereal and sell it as "Arduin-O's"

California
Offline Offline
Faraday Member
**
Karma: 88
Posts: 3352
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The compiler is smart enough to get rid of unused code. Of course, you could always write small example and test it yourself.
Logged

Offline Offline
Edison Member
*
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sometimes a class or variable or interrupt routine is still in the compiled file, even when it is not used.

I use defines to disable blocks of code.

Code:
// Select which one to use

// #define ENABLE_I2C
// #define ENABLE_BLINKING_LED
#define ENABLE_TEMPERATURE

...

#ifdef ENABLE_TEMPERATURE
  // do someting with the temperature sensor
  float temperature = getTemperature();
  Serial.println( temperature);
#endif
Logged

Pages: [1]   Go Up
Jump to: