Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Embedded C programming help.

Status
Not open for further replies.

Tan9890

New Member
Hi.. I have some following codes and i would like 2 know how they function:

void Task(void* data)
{
data=data;
while(1)
{.
.
.
}
}

in this, what is meant by data=data?

also what is the difference between " void* " and something like " *err "?
the star afterwards and before the word..

Please i need the answer urgently.. its for an exam tomorrow.
Thank You.
 
data=data; is pointless, it assigns the value of a variable to that variable. The only thing this assignment will do, apart from waste time if the compiler doesn't optimise it out, is to stop the compiler complaining about an unreferenced variable.

void * X; defines X as a variable of type pointer-to-void. X can point at anything.

*X dereferences X; it takes the memory location stored in X and looks up what is in that memory location.

So if X contains 1000, and memory location 1000 contains the value 5, then a=*X; will assign 5 to a.

The asterisk in a different context means multiply (a=5*7; will assign 35 to a), and can also be used multiple times on a pointer-[to-pointer]^n, e.g
if 1000 contains the value 1004, and 1004 contains the value 1008, and 1008 contains the value 5, and X contains the value 1000, then a=***X; will assign 5 to a.

=* used to be a synonym for *=, so a=*X might need rewriting as a= *X to prevent the compiler trying to multiply a by X, depending on the compiler.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top