Is it possible for C preprocessor macros to contain preprocessor directives?

The Boost Preprocessor (which works for C as well as C++, even though Boost as a whole is a C++ library) library can help with this kind of task. Instead of using an #ifdef within a macro (which isn’t permitted), it helps you include a file multiple times, with different macros defined each time, so … Read more

How to iterate through string one word at a time in zsh

In order to see the behavior compatible with Bourne shell, you’d need to set the option SH_WORD_SPLIT: setopt shwordsplit # this can be unset by saying: unsetopt shwordsplit things=”one two” for one_thing in $things; do echo $one_thing done would produce: one two However, it’s recommended to use an array for producing word splitting, e.g., things=(one … Read more

how to make bash expand wildcards in variables?

A deleted answer was on the right track. A slight modification to your attempt: shopt -s extglob MYDIR=”./images” OTHERDIR=”./images/junk” SUFFIXES=’@(pdf|eps|jpg|svg)’ mv “$MYDIR/”*.$SUFFIXES “$OTHERDIR/” Brace expansion is done before variable expansion, but variable expansion is done before pathname expansion. So the braces are still braces when the variable is expanded in your original, but when the … Read more

Why does shell ignore quoting characters in arguments passed to it through variables? [duplicate]

Why When the string is expanded, it is split into words, but it is not re-evaluated to find special characters such as quotes or dollar signs or … This is the way the shell has ‘always’ behaved, since the Bourne shell back in 1978 or thereabouts. Fix In bash, use an array to hold the … Read more