Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the '__IO' directive in GCC?

Tags:

gcc

embedded

I am working on an embedded device, and there is some code that was originally compiled using the IAR compiler.

I am trying to recompile said code using the GCC compiler.

There is a particular statement: typedef __IO , which simply doesn't get compiled ("Unrecognized symbol error").

Could anyone suggest how I could get this statement to compile properly?

like image 315
Chaitannya Avatar asked Jan 16 '13 13:01

Chaitannya


2 Answers

If it is not recognised it will be because an appropriate system header containing the definition has not been included.

It will be defined in the chip support header file provided with the toolchain. It is type qualifier, or rather a macro (#define) that will expand to a type qualifier. It is used for example as follows:

__IO uint8_t CSSR;

Here uint8_t is the type, so __IO cannot in fact be a typedef because it is not used where a type is valid. The __IO macro expands to whatever the particular compiler requires to ensure correct I/O access and addressing. In the typical case where I/O is memory mapped, it will simply expand to volatile since all I/O should be declared volatile to ensure explicit accesses are not optimised out.

If you want to be sure, download a demo version of the IAR tools and take a look in the header files at how it is defined for your particular architecture. Otherwise you might just use #define __IO volatile

like image 187
Clifford Avatar answered Sep 21 '22 18:09

Clifford


_IO meaning volatile as per in C language...which will not optimize the code and in which value stated for the variable using _IO will be unpredictable or will be changing without knowledge of compiler and user

like image 39
Nithin Avatar answered Sep 22 '22 18:09

Nithin