4 ms·
Taking that pattern to the next level is Mozilla Spidermonkey, which defines a macro and then includes a static data file which calls the macro with its data co
by apaprocki 13y ago
Taking that pattern to the next level is Mozilla Spidermonkey, which defines a macro and then includes a static data file which calls the macro with its data contents. The same table is included multiple times with different macro definitions to output different code. Pre-processor code generation :) Example:
http://hg.mozilla.org/mozilla-central/file/48dbd532a004/js/src/jsopcode.cpp#l60 http://hg.mozilla.org/mozilla-central/file/48dbd532a004/js/s...
- Someone 13y agoThat's pretty normal, if used in moderation. For example, it is a way to define overloads on functions on vectors with floats and double coordinates without having to copy-paste thousands of lines (using sed and make is another) http://www.drdobbs.com/the-new-c-x-macros/184401387 http://www.drdobbs.com/the-new-c-x-macros/184401387 gives nice examples.