17.02.2015 Views

CCS C Compiler Manual PCB / PCM / PCH

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

DATA DEFINITIONS<br />

Data Definitions<br />

Basic Types<br />

Declarations<br />

Non-RAM Data Definitions<br />

Using Program Memory for Data<br />

Function Definition<br />

Declarations<br />

This section describes what the basic data types and specifiers are and how<br />

variables can be declared using those types. In C all the variables should be<br />

declared before they are used. They can be defined inside a function (local) or<br />

outside all functions (global). This will affect the visibility and life of the variables.<br />

A declaration consists of a type qualifier and a type specifier, and is followed by a list<br />

of one or more variables of that type.<br />

For example:<br />

int a,b,c,d;<br />

mybit e,f;<br />

mybyte g[3][2];<br />

char *h;<br />

colors j;<br />

struct data_record data[10];<br />

static int i;<br />

extern long j;<br />

Variables can also be declared along with the definitions of the special types.<br />

For example:<br />

enum colors{red, green=2,blue}i,j,k; // colors is the enum type and<br />

i,j,k<br />

//are variables of that type<br />

SEE ALSO:<br />

Type Specifiers<br />

Type Qualifiers<br />

Enumerated Types<br />

27

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!