Author Topic: Conditional defines  (Read 2879 times)

Offline fpinkse

  • Single posting newcomer
  • *
  • Posts: 3
Conditional defines
« on: March 13, 2010, 01:06:41 pm »
Hi All,

This may well be in the wrong section, but is has to do with using Codeblocks.
It is about right mouse button menu item Find declaration of.....

I have this code
Code
#include <PIC/PIC16F874.H>
// test of #if

#define comtype 0
#if (comtype==0)
    #define ControlPort PORTA
#endif

#if (comtype==1)
    #define ControlPort PORTB
#endif

#if (comtype==2)
    #define ControlPort PORTC
#endif


// CONFIG
    static typedef unsigned int config;
    config at 0x2007 __CONFIG = _PWRTE_OFF & _BODEN_OFF & _WDT_OFF & _LVP_ON & _CPD_OFF & _DEBUG_OFF & _HS_OSC & _CP_OFF;

// main body
void main(){
    ControlPort = 0;
}

When you use the right mouse button menu Find the declaration of ...on ControlPort in the main function you are directed to the very last#define of ControlPort.
I conclude the find does not obey the #if-#endif.

Is this fixable?

Note: the PORTA etc is used here as I wanted the example as small as possible without SDCC optimizing out code.

Thanks.

Frans.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: Conditional defines
« Reply #1 on: March 13, 2010, 06:09:20 pm »
Ask this question on a site supporting the Compiler.
I am not a user of Code Completion; but it has bugs. Need a version number of Code::Blocks for someone else to help you.

Sorry, I did not realize at first it was a Code Completion question.

Tim S.
« Last Edit: March 13, 2010, 06:12:27 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline fpinkse

  • Single posting newcomer
  • *
  • Posts: 3
Re: Conditional defines
« Reply #2 on: March 13, 2010, 09:05:21 pm »
Hello Tim,

I use Code::Blocks version 8.02
My apologies for the omission.

Since the version of SDCC I use is command line driven I concluded that the right mouse menu had to come from Code::Blocks

I just wanted to report something I thought to be not logical.

Frans.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: Conditional defines
« Reply #3 on: March 13, 2010, 10:29:05 pm »
The Code Completion section has changed a lot. You might try the recent nightly to see if the is fixed.

I do not think it is; but, I do not use Code Completion. Note, it is possible the symbols plugin does this instead of Code Completion plugin.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org