Compiler Problem

H

hyderabadblues

Following is an abstract of my code
Compiler is giving me an error at funciton call func1 as argument of
type void * is not compatible with parameter of type VP

typedef void * VP;

struct name
{
int i;
};

void func1(VP* v)
{
}


void main()
{
struct name n1,*n2;
n2=&n1;
func1((void *)&n2); /////////////////
}
 
C

Chris Dollin

hyderabadblues said:
Following is an abstract of my code
Compiler is giving me an error at funciton call func1 as argument of
type void * is not compatible with parameter of type VP

typedef void * VP;

struct name
{
int i;
};

void func1(VP* v)
{
}

`func1` wants a `VP*`. But `VP` is `void*`. So `func1` wants
a `void**` - a pointer to pointer-to-void.
void main()

`int` main. int. INT. `main` returns `int`. Not `void`. `int`.
{
struct name n1,*n2;
n2=&n1;
func1((void *)&n2); /////////////////

`func1` wants a `void**`, but you've given it a `void*`. The
compiler says, quite rightly, that this is wrong.

Since `func1` doesn't do anything, I don't know why you wanted
to pass it a `void**`. If you explain what you're trying to do,
perhaps we can offer constructive advice.
 
E

Eric Sosman

hyderabadblues said:
Following is an abstract of my code
Compiler is giving me an error at funciton call func1 as argument of
type void * is not compatible with parameter of type VP

typedef void * VP;

struct name
{
int i;
};

void func1(VP* v)
{
}


void main()
{
struct name n1,*n2;
n2=&n1;
func1((void *)&n2); /////////////////
}

Are you sure you are compiling this (wretched, horrible)
code with a C compiler and not with a C++ compiler? The two
languages differ in many ways, among them in their treatment
of `void*'.
 
L

Lew Pitcher

Following is an abstract of my code
Compiler is giving me an error at funciton call func1 as argument of
type void * is not compatible with parameter of type VP

typedef void * VP;

Here, you typedef the name VP to a pointer to void
struct name
{
int i;
};

void func1(VP* v)

Here, you say that func1 takes as it's argument a pointer to VP.
Since VP is typedefed as a pointer to void, this means that you've
made func1 require an argument of pointer to pointer to void.
{
}

void main()

Unless you are working in a freestanding implementation, main is
required to return an integer. This should be
int main(void)
{
struct name n1,*n2;
n2=&n1;
func1((void *)&n2); /////////////////

Here, you pass func1 an argument that is a pointer to void. Remember,
you defined func1() to require a pointer to pointer to void, so this
call to func1() has an argument mismatch with the definition.

Also, since main() returns an integer, good programming practice (and
certain backlevels of the C standard) requires that you return an
integer before falling off the end of main(). So
return 0;

HTH
 
H

hyderabadblues

Are you sure you are compiling this (wretched, horrible)
code with a C compiler and not with a C++ compiler? The two
languages differ in many ways, among them in their treatment
of `void*'.


I am using ARM compiler . This is just a small briefing of my code
 
F

Flash Gordon

hyderabadblues wrote, On 19/02/07 16:10:
Please do not quote peoples signatures (the bit after the "-- ") unless
you are commenting on them.
I am using ARM compiler . This is just a small briefing of my code

That is not an answer to Eric's question. I'm sure that if you looked
hard enough you could find an Ada compiler for the ARM processor and
that would not compile C code properly just as a C++ compiler would not
compile all C code properly (and not as C code at all).

Now, are you using a C compiler for the ARM (or a compiler that supports
multiple languages in its C mode) as oppose to, just for instance, a C++
compiler. If you do not know the answer to this question you need to
read the documentation for the compiler and/or ask on a group where the
"ARM compiler" is topical so you can find out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,165
Latest member
JavierBrak
Top