MikroC debugger and #define

Discussion in 'Embedded Systems and Microcontrollers' started by dayv3, Jun 3, 2014.

  1. dayv3

    Thread Starter Member

    May 22, 2014

    I just tried to debug some code in the MikroC for pic compiler and noticed
    that the #define variables do not show up in the "select variables from list"
    drop down box. Is it possible to make them show up in the list so that I can make sure that they are functioning properly when I step thru the code?

    Some 12f683 examples:
    #define LED GPIO.B2 // output led
    #define count_needed 17 // iterations needed
    #define smpl_rate 2 // 2ms

  2. JohnInTX


    Jun 26, 2012
    #define is processed by the C preprocessor by simple text substitution before compilation so it does not create a named variable. #defined values won't show up in the symbol list.

    To see your LED, watch GPIO which is a variable. Things like #define count_needed 17 simply substitute 17 into the C source wherever count_needed appears before compiling:

    x = count_needed; // gets preprocessed to
    x = 17; // and this statement is what gets compiled.

    The name 'count_needed' does not exist after the preprocessor gets done with it. To see what's happening, watch 'x' or whatever your variable is named.

    Welcome aboard!
    Last edited: Jun 3, 2014