EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: unexpanded macros in comments
From: Andrew Johnson <[email protected]>
To: Gasper Pajor <[email protected]>
Cc: EPICS tech-talk <[email protected]>
Date: Tue, 30 Jan 2007 11:52:45 -0600
Hi Gasper,

Gasper Pajor wrote:

I don't expect to find a lot of new EPICS issues these days, so I didn't request a mantis account, although it would be a proper way to file a bug :)

Actually I prefer to get reports by email first, so I can do some triage before they go into Mantis. However, either way works.


Anyway, when starting an IOC (epics 3.14.x on linux) with a template file that has unexpanded macros in comments (i.e. in lines beginning with '#'), the errors are printed to IOC console:

## Load record instances
dbLoadRecords("db/dbExample1.db","user=gpajor")
macLib: macro somemacro is undefined (expanding string # $(somemacro)
)
filename="../dbLexRoutines.c" line number=317
macExpandString failed for file db/dbExample1.db

I think the macro expanding mechanism should disregard the comment lines.

Unfortunately this is not currently possible because of the order in which we parse the .db files - macro expansion takes place before the text gets fed to the tokenizer and parser, so when we're looking up the macro values we don't know whether we're currently parsing a comment line or not.


There are advantages and disadvantages in this, and unfortunately I don't know whether anybody is making use of the addtional capabilities this provides. For example, this record definition and dbLoadRecords line are legal as far as the IOC's parser are concerned:

record($(type),"$(name)"){
  field($(field))
}

dbLoadRecords("db/example.db","type=ai,name=input,field='DTYP, xy240'")

I suspect that no tool like VDCT would accept the .db file, but if my understanding is correct the IOC would be perfectly happy with it. It would even be possible to start a comment inside a macro value, although that would be a rather strange thing to do.

I'm not saying I particularly like the way this has been implemented, but that's what the code we currently have does, and before I can change it I would have to poll the community to see whether anybody is relying on it.

Any comments from unconventional users of macros like the above record definition would be appreciated, in case we decide to change things in the future.


There is a way to prevent the error message associated with an undefined macro, which is to give the macro a default value. The following comment line should not generate any errors from dbLoadRecords:


# $(macro=)

The equals sign is used to introduce a value to be used in the event that the macro doesn't exist at the time it's expanded, and this may be sufficient for your purposes. This syntax has been supported by macLib since Base R3.14.6.

- Andrew
--
The right to be heard does not automatically include
the right to be taken seriously. -- Hubert H. Humphrey

Navigate by Date:
Prev: "Heartbeat" databases or sequences? Kay-Uwe Kasemir
Next: RE: StreamDevice and checksum Denison, PN (Peter)
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: "Heartbeat" databases or sequences? Kay-Uwe Kasemir
Next: AAI and AAO Record support David Dudley
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 10 Nov 2011 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·