This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

MACROS TOO NESTED

Hi all, I have a code already written on an 8051 based controller, in which I am enabling some features through Preprocessor Directives. In that process, I am struck at the following error.

C51 COMPILER V7.50 - SN: K1DQP-01744E
COPYRIGHT KEIL ELEKTRONIK GmbH 1987 - 2004
C51 FATAL-ERROR - ACTION: PARSING SOURCE-FILE ERROR: PREPROCESSOR: MACROS TOO NESTED
C51 TERMINATED.

Kindly let me know what does this error mean and how to rectify this?
Awaiting your reply.
Regards,
Balaji

Parents
  • One macro will expand into another macro that will expand into yet another in too many steps.

    Getting into troubles with too deep nesting normally indicates something wrong in the software design. A developer would also have to perform the macro expansion in his/her head to visualise the "real" code, or would be required to run the preprocessor to create a preprocessed source. Whenver an experienced developer can't understand the code he is reading, it is time to consider if the code is well written.

Reply
  • One macro will expand into another macro that will expand into yet another in too many steps.

    Getting into troubles with too deep nesting normally indicates something wrong in the software design. A developer would also have to perform the macro expansion in his/her head to visualise the "real" code, or would be required to run the preprocessor to create a preprocessed source. Whenver an experienced developer can't understand the code he is reading, it is time to consider if the code is well written.

Children
  • NEVER-EVER use macros to do more than a very-very simple thing like:

    abs( x ); -or-
    max( x, y );

    I once saw [a retard's] code in which he used macros everywhere. I then chose to ban all macros in the company (my rule-book).

    The only exception is if the code-monkey obtains a waiver from either the customer, or project manager.

    And yes I know there can be a fine-line between a #define and a macro.

    I don't think you are saving much time when implementing [nested] macros: errors can be hard to track down too.

    --Cpt. Vince Foster
    2nd Cannon Place
    Fort Marcy Park, VA

  • There are macros that make code more readable and there are macros that makes it non-readable, non-debuggable, non-...

    It seems that there are two principal directions a) no macros and b) too many macros.

    I lean towards a use of macros for exceptions only e.g. if a function is entered with e.g. a variable that is too large it will call PGM_ERR().

    Erik

  • "I then chose to ban all macros in the company (my rule-book)."

    I take it you don't drink alcohol, then?

  • Toward the bottom you'll see that I do drink alcohol from time to time.

    http://www.keil.com/forum/docs/thread15341.asp

    15mg Hydrocodone, 650mg of APAP, 20mg Diazapam, 350mg of Cordosiporol, 1.5 shots of Bacardi 151, one "Rules for Coding [Monkey] Radicals," one fulll lip of Copenhagan, and bio-lab bunker level #3 with elevated O2 levels. Yet I still function at a higher strata than a sardine: 999.

    --Cpt. Vince Foster
    2nd Cannon Place
    Fort Marcy Park, VA