EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Coding style question IOCFUNCDEF_HAS_USAGE
From: "Johnson, Andrew N. via Core-talk" <core-talk at aps.anl.gov>
To: Heinz Junkes <junkes at fhi-berlin.mpg.de>
Cc: EPICS core-talk <core-talk at aps.anl.gov>
Date: Wed, 13 Jan 2021 16:42:59 +0000
On Jan 13, 2021, at 7:03 AM, Heinz Junkes via Core-talk <core-talk at aps.anl.gov> wrote:

In EPICS 7, a macro IOCFUNCDEF_HAS_USAGE is defined in ioch.h.

Taking that into account, my code looks like this (it's not "pretty") :

----
static const iocshFuncDef rtshellFuncDef = { “rt”,2, rtshellArgs
#ifdef IOCFUNCDEF_HAS_USAGE
  , “run rtems shell command”
#endif
                                          };
----

How do you get it to look nice?

It doesn’t look as bad if you don’t use that huge indentation (personally I dislike that indent style, it gets line-wrapped in emails and any changes to the variable name mean you have to redo the number of spaces in the indentation of all the lines below it). I would probably write it like this:

static const iocshFuncDef rtshellFuncDef = {
    “rt”, 2, rtshellArgs
    #ifdef IOCFUNCDEF_HAS_USAGE
        , “run rtems shell command”
    #endif
};


You could also define your own macro:

#ifdef IOCFUNCDEF_HAS_USAGE
#define IOCSH_USAGE(msg) ,msg
#else
#define IOCSH_USAGE(msg)
#endif

Then the code becomes:

static const iocshFuncDef rtshellFuncDef = {
    “rt”, 2, rtshellArgs
    
IOCSH_USAGE(“run rtems shell command”)
};


- Andrew

-- 
Complexity comes for free, simplicity you have to work for.


References:
Coding style question IOCFUNCDEF_HAS_USAGE Heinz Junkes via Core-talk

Navigate by Date:
Prev: Re: [Merge] ~bfrk/epics-base:remove-dbfl_type_rec into epics-base:7.0 mdavidsaver via Core-talk
Next: Question about travis-ci Mark Rivers via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024 
Navigate by Thread:
Prev: Coding style question IOCFUNCDEF_HAS_USAGE Heinz Junkes via Core-talk
Next: Question about travis-ci Mark Rivers via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024 
ANJ, 13 Jan 2021 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·