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
conditional compilation
-
- Posts: 174
- Joined: 31 Aug 2009 22:44
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
<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
-
- Posts: 174
- Joined: 31 Aug 2009 22:44
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
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
- tihomir.losic
- mikroElektronika team
- Posts: 2138
- Joined: 02 Dec 2009 14:16
- Location: Serbia
- Contact:
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
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]
-
- Posts: 174
- Joined: 31 Aug 2009 22:44
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
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