Jump to content
Sign in to follow this  

Longer Macro Body

Recommended Posts

I would like to request a larger macro body limit (about 50% larger than it is now with BoostC 7.051, maybe 2x larger). The current limit is pretty good (it's better than other compilers I have tried), and is one of the reasons I chose BoostC. However, I have some very complex macros, and some of them go over the macro body length limit. To get them to compile requires awkward work-arounds like spltting up the macro or pre-expanding multiple copies of it with known parameters and then wrapping them in inline functions - this clutters up the code considerably.


BTW, these macros are so complex because I need very efficient code, so I am forcing the compiler to reduce the expressions into simple constants at compile-time. Here is a very simplified example:


#define VALUE (other_value == 3)? expresson_one: expression_two


Assuming "other_value" is a constant and "expression_one" and "expression_two" are also, this entire expression can be reduced to a simple constant at compile time. However the ternary "?:" operator seems to prevent most C compilers from doing this, so a conditional code is generated and adds to run-time overhead. To work around that issue, I use a macro such as the following:


#define IIF(expr, tval, fval) ((((expr)!=0)*(tval)) + (((expr)==0)*(fval))) //in-line IF


This macro nicely reduces the entire conditional expression to a simple compile-time constant, but if "expr" is complex, this can easily go over the macro body length limit (because "expr" appears twice within the macro body).


I have other examples, but hopefully this has presented a case for a longer macro body length limit.





Share this post

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...