Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

8.1.2 One Macro Call

Let's proceed on the interaction between active characters and macros with this small macro, which just returns its first argument:

     define([car], [$1])

The two pairs of quotes above are not part of the arguments of define; rather, they are understood by the top level when it tries to find the arguments of define. Therefore, assuming car is not already defined, it is equivalent to write:

     define(car, $1)

But, while it is acceptable for a configure.ac to avoid unnecessary quotes, it is bad practice for Autoconf macros which must both be more robust and also advocate perfect style.

At the top level, there are only two possibilities: either you quote or you don't:

     car(foo, bar, baz)
     =>foo
     [car(foo, bar, baz)]
     =>car(foo, bar, baz)

Let's pay attention to the special characters:

     car(#)
     error-->EOF in argument list

The closing parenthesis is hidden in the comment; with a hypothetical quoting, the top level understood it this way:

     car([#)]

Proper quotation, of course, fixes the problem:

     car([#])
     =>#

Here are more examples:

     car(foo, bar)
     =>foo
     car([foo, bar])
     =>foo, bar
     car((foo, bar))
     =>(foo, bar)
     car([(foo], [bar)])
     =>(foo
     define([a], [b])
     =>
     car(a)
     =>b
     car([a])
     =>b
     car([[a]])
     =>a
     car([[[a]]])
     =>[a]

With this in mind, we can explore the cases where macros invoke macros...


 
 
  Published under the terms of the GNU General Public License Design by Interspire