problem with compilation

S

seema

Hi all,
I am new to C programming. I have problem compiling a sample ,

#include <stdio.h>

int getuniqueaddress1(){
return 1;
}
int getuniqueaddress2(){
return 2;
}

int getuniqueaddress3(){
return 3;
}

typedef struct IRpcStubBufferVtbl
{
int wuEpad10; int wuEpad20; int wuEpad30;

}IRpcStubBufferVtbl;
struct IRpcStubBuffer
{
struct IRpcStubBufferVtbl *lpVtbl;
};

typedef struct tagCInterfaceStubVtbl
{
IRpcStubBufferVtbl Vtbl;
} CInterfaceStubVtbl;

const CInterfaceStubVtbl _IClassFactoryStubVtbl =
{
getuniqueaddress1(),getuniqueaddress2(),getuniqueaddress3()

};

int main()
{

}
Any idea about why I am hitting compilation error? Any work around for
fixing this problem?

Thanks in advance,
Seema
 
A

Artie Gold

seema said:
Hi all,
I am new to C programming. I have problem compiling a sample ,

#include <stdio.h>

int getuniqueaddress1(){
return 1;
}
int getuniqueaddress2(){
return 2;
}

int getuniqueaddress3(){
return 3;
}

typedef struct IRpcStubBufferVtbl
{
int wuEpad10; int wuEpad20; int wuEpad30;

}IRpcStubBufferVtbl;
struct IRpcStubBuffer
{
struct IRpcStubBufferVtbl *lpVtbl;
};

typedef struct tagCInterfaceStubVtbl
{
IRpcStubBufferVtbl Vtbl;
} CInterfaceStubVtbl;

const CInterfaceStubVtbl _IClassFactoryStubVtbl =
Identifiers beginning with an underscore followed by a capital letter
are reserved to the implementation.
{
getuniqueaddress1(),getuniqueaddress2(),getuniqueaddress3()
Static (in this case file scope) variables must be initialized with
*constants* (if they're explicitly initialized) in C. Move the
declaration into main() and pass as needed.
};

int main()
{

}
Any idea about why I am hitting compilation error? Any work around for
fixing this problem?
See above.

Next time, however, be sure to include the compilation errors you get.

HTH,
--ag
 
S

seema

Here is the compilation error i get when I compile this program on
HP-UX,
"xsample2.c", line 31: error #2059: function call is not allowed in a
constant
expression
getuniqueaddress1(),getuniqueaddress2(),getuniqueaddress3()
^

"xsample2.c", line 31: error #2146: too many initializer values
getuniqueaddress1(),getuniqueaddress2(),getuniqueaddress3()
^

2 errors detected in the compilation of "xsample2.c"
Artie said:
seema said:
Hi all,
I am new to C programming. I have problem compiling a sample ,

#include <stdio.h>

int getuniqueaddress1(){
return 1;
}
int getuniqueaddress2(){
return 2;
}

int getuniqueaddress3(){
return 3;
}

typedef struct IRpcStubBufferVtbl
{
int wuEpad10; int wuEpad20; int wuEpad30;

}IRpcStubBufferVtbl;
struct IRpcStubBuffer
{
struct IRpcStubBufferVtbl *lpVtbl;
};

typedef struct tagCInterfaceStubVtbl
{
IRpcStubBufferVtbl Vtbl;
} CInterfaceStubVtbl;

const CInterfaceStubVtbl _IClassFactoryStubVtbl =
Identifiers beginning with an underscore followed by a capital letter
are reserved to the implementation.
{
getuniqueaddress1(),getuniqueaddress2(),getuniqueaddress3()
Static (in this case file scope) variables must be initialized with
*constants* (if they're explicitly initialized) in C. Move the
declaration into main() and pass as needed.
};

int main()
{

}
Any idea about why I am hitting compilation error? Any work around for
fixing this problem?
See above.

Next time, however, be sure to include the compilation errors you get.

HTH,
--ag


--
Artie Gold -- Austin, Texas
http://goldsays.blogspot.com
"You can't KISS* unless you MISS**"
[*-Keep it simple, stupid. **-Make it simple, stupid.]
 
V

Vladimir S. Oka

said:
Here is the compilation error i get when I compile this program on

<snip error messages>

First, please don't top-post (I corrected it this time).

Second, there was no reason, or value, in posting compilation errors
after you were given explanation of the problem, especially as Artie
correctly guessed what your problem was, and gave advice how to fix it.
 

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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top