wiki:PerTaskCflags

Version 2 (modified by Nicolas Pouillon, 18 years ago) (diff)

--

You may define some flags to be passed to tasks at compile time. They will be added to compile line as -DKEY=value on every source file for a given task

Usage examples

tg = TaskModel(
        'tg',
        outfifos = ['output'],
        impl = [ SwTask( 'tg',
                         stack_size = 4096,
                         sources = [ 'src/tg_posix.c' ],
                         defines = ['FILE_NAME', 'NB_ITER'] )
               ] )

tg_inst = Task(
        tg, 'tg_inst_0',
        portmap = { 'output':fifo_to_app },
        defines = { 'FILE_NAME':'"plan.jpeg"', 'NB_ITER':'4' } )

Yes, have double quotes for strings so that the name is still a string when it comes to C...

Warning

Defined values when compiling a C file are unpredictable if

  • This C file is shared between tasks
  • The task corresponding to the C-file is instanciated more than once with different defines

If the only purpose is to pass up a numeric value, you should use consts.