2

I'm experiencing a weird issue with Visual Studio 2015. Whenever I use the macro below the function I'm using it in becomes undefined to Visual Studio. Worth to mention that this is only a visual issue and doesn't cause any problems while compiling. Also worth to mention that this is only happening when I use a variable as the max value. Here's the macro:

#define fiz(MAX_VALUE) for (unsigned int i = 0; i < (MAX_VALUE); i++)

void functionFoo() 
{
    unsigned int max_val = 10;
    fiz(max_val) { // if I use 10 here I don't experience the same issue
        /* do stuff */
    }
}

Edit: So my question is, did anyone else experience same/similar issue and if they were able to fix it? Edit2: Upon further searching I came across this question. Apparently this issue(or according to the article a performance related design choice) has been existing since Visual Studio 2005. Following the solution in that link has fixed the problem.

8
  • create i before the loop and initialize it in the loop
    – Jguillot
    Oct 14, 2016 at 14:52
  • @Jguillot Thanks for the quick reply. Still experiencing the same issue regardless of where I declare i
    – AcarX
    Oct 14, 2016 at 14:56
  • 1
    What does the compilator say?
    – Jguillot
    Oct 14, 2016 at 14:58
  • There're no issues with compiling so it doesn't say anything. It's a visual bug which is causing my function declarations to be displayed as undefined.
    – AcarX
    Oct 14, 2016 at 15:09
  • What is the question? You forgot to ask one. Oct 14, 2016 at 15:16

1 Answer 1

0

MAX_VALUE is an existing definition, so your macro get 'macrod' by replacing the MAX_VALUE with a large integer number.

Then, the line in your code does not match the macro definition, and cannot be replaced.

Try using another word (any other) than MAX_VALUE.

1
  • Hi. Sadly changing the parameter name didn't solve the issue(tried with MYMAXVAL)
    – AcarX
    Oct 16, 2016 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.