conditional compilation

General discussion on mikroBasic PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
peterverkaik
Posts: 174
Joined: 31 Aug 2009 22:44

conditional compilation

#1 Post by peterverkaik » 15 Jan 2010 12:02

Hi,

Currently I use the compiler directive #I to split up
my program file. This way I can use #defines prior to #I
and use the defines for conditional compilation of the #I file.

However, the #I file can then not be a true library file (eg. module)

Would it be possible to declare #defines prior to include statements,
and that the compiler remembers those #defines and applies them
to the library files for conditional compilation?

regards peter

peterverkaik
Posts: 174
Joined: 31 Aug 2009 22:44

#2 Post by peterverkaik » 18 Jan 2010 17:49

I found out I can accomplish it by defining
<symbol>=<value>
into a .pld file and adding the pld file to Project Level Defines

Now I have a problem with a predefined value.
In the help
#ifdef P30F4013
...
#endif

that works, but
#ifdef __FOSC__ == 80000
...
#endif

seems not to work, that is, I cannot use __FOSC__ to
be used in a calculation.

Since the devicetype is set to a project level define,
why are there not predefined project level defines for pic
builtin hardware for the selected device, like SPI1, U1, U2, etc.
That would make it easier to write code for a specific hardware
module, like Uart2, without considering the device.
A device not having the hardware module, would not have
its specific hardware token set.


regards peter

peterverkaik
Posts: 174
Joined: 31 Aug 2009 22:44

#3 Post by peterverkaik » 18 Jan 2010 18:31

I defined in a pld file
STARTUP_BUTTON_WAIT=1
and added the pld file to Project Level Defines in Project manager.

Using under Main: in program file

'startup wait
#if STARTUP_BUTTON_WAIT == 1
'code
#endif

yields error
563 301 "#if STARTUP_BUTTON_WAIT == 1 "is not valid identifier

It appears the project level defines are not visible in the program
file.

regards peter

User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

#4 Post by tihomir.losic » 19 Jan 2010 16:23

Hello,

Please post this question on our Support Desk:
http://www.mikroe.com/en/support/
Also, send me attachment with your whole project if possible, I need that to check where is the problem in your program in order to solve soon as possible.

Thanks.

Regards,

Losic Tihomir
mikroElektronika [Support team]

peterverkaik
Posts: 174
Joined: 31 Aug 2009 22:44

#5 Post by peterverkaik » 20 Jan 2010 15:13

The solution you provided via support ticket is the
solution I mentioned in the first post of this thread.

Problem with #define is that they only work in other files
if I use #I and declare the defines before #I.

For seperate modules, the pld files should be used,
so why does the program not work with the tokens declared
in a pld file (it shpuld).

regards peter

Post Reply

Return to “mikroBasic PRO for dsPIC30/33 and PIC24 General”