4 ms·
I've worked in a lot of situations with C/C++ code and non-programmers, and that simply wouldn't work. Non-programmers will break your build with such a mechan
by chubot 13y ago
I've worked in a lot of situations with C/C++ code and non-programmers, and that simply wouldn't work. Non-programmers will break your build with such a mechanism. If they are capable of editing comma-separated lists of numbers in a text editor without breaking it, they are capable of editing a C file with a float[][] declaration at the top.
It would cause a problem after about 2 days, and then you would end up replacing this in 5 minutes with a 5 line Python script that does a minimal amount of error checking (or a higher level tool to generate the data, e.g. a game logic editor).
EDIT: A cute hack is one that lets you take a shortcut and saves you time. This is one that saves a tiny amount of typing (or writing 5 lines of Python), in exchange for wasting time with broken builds.
- apaprocki 13y agoTaking 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.