Jump to content
Sign in to follow this  
djulien

A Way For Preprocessor Reduce Expressions

Recommended Posts

I would like to request the equivalent of MPASM's #v(expr) operator.

It is useful to put actual values into #error or #warning messages for compile-time debug, or for informational purposes. However, this currently doesn't work well with macros that contain expressions. For example,

 

#define VALUE  (computed value here)
#warning "using value = "VALUE"."

 

will show a message something like:

file(line): WARNING: using value = "(((1<<5 & 0xF0) + (45 << 5 & 0xEFF0)) == 0) * (0xE6 * (((130) * 54)) + 1)/ 52)".

 

It would be more helpful to see a message such as:

file(line): WARNING: using value = 12.

 

It would also be very helpful to be able to specify the radix, so that the value can be displayed in decimal, hex, or even binary. For example, maybe make #d(expr) and #x(expr) operators, or just a generic #v operator with a radix parameter so that decimal would be displayed by #v(expr, 10), hex would be displayed with #v(expr, 16), etc.

 

don

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
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.

Loading...
Sign in to follow this  

×