Thread: I want to exclude functions on compile time. Options?

  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    1

    Lightbulb I want to exclude functions on compile time. Options?

    Hi All.

    I am working on a project, where I have to be able to exclude some code fast and dynamicly at compiletime.

    I got a scheduler running and actually I just want to remove some of the tasks from it - but at compile time so that the code wont take up space in my microcontroller.

    I know that I can use macros like #ifdef #endif etc. But I think that method makes the code unreadable and complicated.

    Any ideas how to archive such functionality a more elegant way?

    Thanks in advance
    Last edited by Jonas West Alrĝ; 03-06-2013 at 09:06 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > I know that I can use macros like #ifdef #endif etc. But I think that method makes the code unreadable and complicated.
    Perhaps you should separate the code into multiple files then.

    If you
    - put one function in each source file
    - compile all the variant source files to produce a library
    - then link you configured scheduler with that library

    Then you will have only the code you need.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 01-12-2013, 10:11 AM
  2. Getting compile time.
    By ThatDudeMan in forum C Programming
    Replies: 2
    Last Post: 10-13-2010, 12:15 PM
  3. Replies: 2
    Last Post: 09-11-2007, 03:57 PM
  4. g++ compile options
    By cybernike in forum Linux Programming
    Replies: 2
    Last Post: 07-05-2007, 12:09 AM