could we optimize abdrive.h

Why abdrive.c include some header for string and text ?
#include "simpletools.h"
#include "simpletext.h"
#include <string.h>

could those be safely removed ?

Comments

  • 7 Comments sorted by Date Added Votes
  • simpletools.h File Reference
    This library provides convenient functions for a variety of microcontroller I/O, timing, conversion, and communication tasks. This library also includes (and you can call functions from) simpletext and serial. More...

    #include <propeller.h>
    #include "simpletext.h"
    #include <driver.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <cog.h>
    #include <ctype.h>
    #include <unistd.h>
    #include <sys/stat.h>
    #include <dirent.h>
    #include <sys/sd.h>
    #include <math.h>
    #include "simplei2c.h"
    Florida, between St. Petersburg and the Gulf of Mexico

    Do not look directly into laser with remaining good eye...
  • my concern is that my code don't use any string output. i don't use the terminal indeed.
    So i would like to save a few memory to get rid of the string.h or simpletext.h.

    anyway, abdrive is only for encoders or servo drive. it should not be about text.
  • Just an observation Laurent but to "like" to save memory is not normally a pressing reason. Memory is there to be used, not to be saved, and only if you get to the point where memory is being fully utilized then more than likely you would be utilizing simpletext anyway. The Propeller has 8 cogs and your application mightn't even use half of them etc but they come with the package, same with the libs.
    useforthlogo-s.png
    LINKS
    Brisbane, Australia
  • laurent974 wrote: »
    my concern is that my code don't use any string output. i don't use the terminal indeed.
    So i would like to save a few memory to get rid of the string.h or simpletext.h.

    anyway, abdrive is only for encoders or servo drive. it should not be about text.

    I like your way of thinking and you are right there.

    abdrive should not need them headers, except if some constants or debug stuff is in there.

    but you do not need to worry, because PropGCC does not include all of this into your created binary for the propeller, just stuff you USE in your code.

    Enjoy!

    Mike


    I am just another Code Monkey.

    A determined coder can write COBOL programs in any language. -- Author unknown.

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
  • Using #include doesn't create code or take space, it just declares that some things exist "somewhere else", and specifies the format for those things. The linker is the part that takes all the libraries and your code, figures out what is actually used, and discards the rest. If you don't use the SimpleText functions, you will not end up with that code in your program, even if you include the headers.
  • As Jason said. Including header files won't increase memory usage. It's only information for the compiler. The exception would be if somebody put C code into a header file, which is something no C programmer should do. You won't find any C code in those header files included by simpletools.h
  • Even if there is code in header files (inline functions are really the only excuse for this), the functions there still won't take up any space if they aren't used.
Sign In or Register to comment.