Preprocessor pre-defined macros

Beta Testing discussion on mikroC PRO for AVR.
Post Reply
Author
Message
David Prentice
Posts: 8
Joined: 30 Oct 2008 12:23

Preprocessor pre-defined macros

#1 Post by David Prentice » 30 Oct 2008 12:40

The C compiler appears to understand __DATE__ and __TIME__

Is there a __COMPILER__ or __DEVICE_CLOCK__ or __DEVICE__ macro so that I can make some attempt to port regular C code ?

I note that the AVR special function registers are accessed as sfrb but most other compilers treat the bit values like TXEN as just a regular integer constant.

So one would set the TXEN bit in UCSRB by: UCSRB |= (1<<TXEN);
I assume that you would use: TXEN = 1;
in a similar manner to 8051 compilers.

I also note that you do not seem to have regular <stdio.h> or <string.h> system header files.

So presumably the compiler knows all library function prototypes without the source code specifying the relevant <lcd.h> etc.

David.
Last edited by David Prentice on 30 Oct 2008 15:46, edited 1 time in total.

User avatar
rajkovic
mikroElektronika team
Posts: 694
Joined: 16 Aug 2004 12:40

Re: Preprocessor pre-defined macros

#2 Post by rajkovic » 30 Oct 2008 15:02

David Prentice wrote:The C compiler appears to understand __DATE__ and __TIME__

Is there a __COMPILER__ or __DEVICE_CLOCK__ or __DEVICE__ macro so that I can make some attempt to port regular C code ?
we are working on it.
this is how it will be (part of future help):
"There are 2 predefined project level defines for any project you make. These defines are based on values that you have entered/edited in the current project:

one is equal to the name of selected device for the project i.e. if ATmega16 is selected device then ATmega16 token will be defined as 1 so, it can be used for conditional compilation.
#ifdef ATmega16
#endif
second is __FOSC__ value of frequency (in Khz) for which the project is build
User can define custom project level defines."

I note that the AVR special function registers are accessed as sfrb but most other compilers teat the bit values like TXEN as just a regular integer constant.

So one would set the TXEN bit in UCSRB by: UCSRB |= (1<<TXEN);
I assume that you would use: TXEN = 1;
in a similar manner to 8051 compilers.
yes we have introduced bit variables and take advantage of that approach.
I also note that you do not seem to have regular <stdio.h> or <string.h> system header files.

So presumably the compiler knows all library function prototypes without the source code specifying the relevant <lcd.h> etc.

Library manager lets you select libraries that you want to use by simple
click no need for headers or additional work. All selected libraries becomes accessible, visible from any project file you can see this by hitting CTRL+SPACE

David Prentice
Posts: 8
Joined: 30 Oct 2008 12:23

#3 Post by David Prentice » 30 Oct 2008 16:27

Thankyou for your prompt reply.

So currently there is no way of identifying the MikroElekronika compiler. I rather assumed that you would have a predefined __MIKROC_AVR__ or some other symbol.

I would prefer a double underscore type of "Compiler reserved" macro __FOSC__ does not imply any particular vendor. ATmega32 will only refer to one particular build and NO particular vendor.

It appears that a "Library" selection quietly provides the associated function prototypes that a conventional <library.h> should do. Creating a directory full of Ansi library dummy header files would solve the "missing header file" errors.

By the time that you have created a large user base of non-conforming C code, you should be able to discourage them from migrating to conforming tools.

I note that you cannot remove a Source file from a project by right-clicking. The icon method does work though.

David

User avatar
rajkovic
mikroElektronika team
Posts: 694
Joined: 16 Aug 2004 12:40

#4 Post by rajkovic » 31 Oct 2008 08:01

David Prentice wrote:Thankyou for your prompt reply.

So currently there is no way of identifying the MikroElekronika compiler. I rather assumed that you would have a predefined __MIKROC_AVR__ or some other symbol.
we will add one for official release, thanks for suggestion
I would prefer a double underscore type of "Compiler reserved" macro __FOSC__ does not imply any particular vendor. ATmega32 will only refer to one particular build and NO particular vendor.
we have already used __FOSC for PIC compiler, maybe we can add
__FOSC__ and keep __FOSC for compatibility.
It appears that a "Library" selection quietly provides the associated function prototypes that a conventional <library.h> should do. Creating a directory full of Ansi library dummy header files would solve the "missing header file" errors.
nice suggestion we will consider this.
I note that you cannot remove a Source file from a project by right-clicking. The icon method does work though.
added to bug list, will be checked and fixed.

Post Reply

Return to “mikroC PRO for AVR Beta Testing”