Return Value of a Function

Status
Not open for further replies.

pavan.emb

Newbie level 5
Joined
Oct 21, 2009
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Bengaluru
Activity points
1,364
Hi all,

I am writing an interfacing program for AT28C64B with C8051F120 microcontroller.

But my doubt is " I want to return the STATUS for Write function whether Success or not. I may use an int or char for this. But what I am Thinking is, is it possible to return bit type for a function."


Also i want to know whether I can pass a bit as an argument to a function or not.

Thanks in advance.
 

U think you may be using Silabs IDE....
which compiler ru using?
some compilers support bit data type.... if so u can use it
 

you can create your own enum data type. I usually just use int, but if you insist, you can do something like:

typedef enum _status_T{FAIL = 0, SUCCESS}status_T;

then you can use your function like:

status_T check_something(){

if(yes)
return SUCCESS;

else
return FAIL;
}
 

...you can create your own enum data type...

Despite more complex, is an excelent idea, due other informations can be passed simultaneously.
The program also become more professional.

+++
 

You cannot pass a bit to a function. Nor can you obtain a bit response.
The smallest unit of data you can probably pass will be a byte.
(Unless you are using something unusual)

Your compiler may make it appear to be passing a bit however it
will simply be extracting the bit from the byte for you in the function.

The choice is:
You could allow this to happen if your compiler does this with a "bit" type
or
You can extract the bit from a char/byte or whatever manually yourself
such as pk_volt suggested.

jack
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…