Operating System - HP-UX
1753500 Members
4520 Online
108794 Solutions
New Discussion юеВ

Erros when using -D_HPUX_API_LEVEL=20040821

 
SOLVED
Go to solution
Srimalik
Valued Contributor

Erros when using -D_HPUX_API_LEVEL=20040821

I have a program which is not compatible with long hostnames/nodename. To make it compatible I tried to compile it with D_HPUX_API_LEVEL=20040821 but the following errors were thrown by aCC.

bash-3.2# aCC -D_HPUX_API_LEVEL=20040821 long_hostname.c
Error 19: "/usr/include/sys/utsname.h", line 73 # Unexpected 'utsname'.
struct __UTSNAME_VERSION_V2_ATTR utsname {
^^^^^^^
Error 373: "/usr/include/sys/utsname.h", line 73 # Old-style function definition parameter must be a simple identifier.
struct __UTSNAME_VERSION_V2_ATTR utsname {
^^^^^^^^^^^^^^^^^^^^^^^^^
Error 43: "/usr/include/sys/utsname.h", line 73 # C++ does not allow Old-style (non-prototype) function definitions.
struct __UTSNAME_VERSION_V2_ATTR utsname {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error 305: "/usr/include/sys/utsname.h", line 73 # Function definitions must return completed object type or void.
struct __UTSNAME_VERSION_V2_ATTR utsname {
^^^^^^^^^^^^^^^^^^^^^^^^^
Warning 361: "/usr/include/sys/utsname.h", line 73 # Value-returning function might end without executing a return statement.
struct __UTSNAME_VERSION_V2_ATTR utsname {
^^^^^^^^^^^^^^^^^^^^^^^^^
Error 20: "/usr/include/sys/utsname.h", line 91 # '{' expected before '__attribute__'.
extern int uname(struct utsname *) __UNAME_VERSION_ATTR;
^^^^^^^^^^^^^^^^^^^^
Error 284: "/usr/include/sys/utsname.h", line 91 # Called function must return completed object type or void.
extern int uname(struct utsname *) __UNAME_VERSION_ATTR;
^^^^^^^^^^^^^^^^^^^^
Warning 361: "/usr/include/sys/utsname.h", line 91 # Value-returning function might end without executing a return statement.
extern int uname(struct utsname *) __UNAME_VERSION_ATTR;
^^^^^
Error 628: "long_hostname.c", line 8 # "utsname n" ["long_hostname.c", line 8] cannot be defined to have an incomplete type.
struct utsname n;
^
Error 548: "long_hostname.c", line 14 # The expression on the left side of the '.' (dot member access operator) must be a completed class object type; the
type of the left side is 'tentative struct utsname' and 'struct utsname' has not been defined yet.
intf("sysname=%s, release=%s, version=%s\n",n.sysname,n.release,n.version);
^
Error 20: "long_hostname.c", line 2716 # '}' expected before ''.
bash-3.2#



Here is a sample .

bash-3.2# cat long_hostname.c
#include
#include
#define SYS_NMLN1 257
#define SNLEN1 257

int main()
{
struct utsname n;
int ret;
ret = uname(&n);
printf("ret = %d" , ret);
if(ret >=0 )
{
printf("sysname=%s, release=%s, version=%s\n",n.sysname,n.release,n.version);
}
else
{
perror("Uname");
}
return 0;
}


Has somebdy seen these errors before?

abandon all hope, ye who enter here..
8 REPLIES 8
Dennis Handly
Acclaimed Contributor

Re: Erros when using -D_HPUX_API_LEVEL=20040821

>I have a program which is not compatible with long hostnames/nodename.

What version of aC++ do you have? It is highly likely that version doesn't support this functionality.
Srimalik
Valued Contributor

Re: Erros when using -D_HPUX_API_LEVEL=20040821

aCC version is 3.37. I also think that this is too old for this.

abandon all hope, ye who enter here..
Srimalik
Valued Contributor

Re: Erros when using -D_HPUX_API_LEVEL=20040821

upgrading the compiler is not possible :-(

I think I have only these options left if -D_HPUX_API_LEVEL=20040821 does not work:

-ignore EOVERFLOW as I am not interested in utsname.nodename. But this behavior can change
in any new HPUX release. EOVERFLOW and population of utname can be made mutually exclusive.

- Set tunable uname_eoverflow=0 as we do not care about the nodename field.

-use something else instead of uname(2M). e.g popen("uname -r") etc. to get the data

Do you know of any more methods?

-Sri
abandon all hope, ye who enter here..
Dennis Handly
Acclaimed Contributor

Re: Erros when using -D_HPUX_API_LEVEL=20040821

>upgrading the compiler is not possible :-(

Why? You are using A.03.37 but the first compiler that was supported for 11.23 is A.03.55.
You need at least A.03.39.

>Do you know of any more methods?

Call uname(2) in a C source, using a newer C compiler.
Srimalik
Valued Contributor

Re: Erros when using -D_HPUX_API_LEVEL=20040821

>Call uname(2) in a C source, using a newer C compiler.

:-(. I have fixed the app to not to use uname.

But on IA i am facing a strange issue, the application does not even start and it dumps with "unknown error" as soon as its started. even main() not getting called.

when I set the hostname to less then 8 chars or set uname_eoverflow to 0 it starts without problems. Is this is known issue with aries/linker on systems with long hostnames?

Thanks
Sri
abandon all hope, ye who enter here..
Dennis Handly
Acclaimed Contributor
Solution

Re: Erros when using -D_HPUX_API_LEVEL=20040821

>Is this is known issue with aries/linker on systems with long hostnames?

Yes, this is a known problem with dld.
PHSS_39093 11.23 linker + fdp cumulative patch
PHSS_39094 11.31 linker + fdp cumulative patch
Srimalik
Valued Contributor

Re: Erros when using -D_HPUX_API_LEVEL=20040821

Thanks Dennis
abandon all hope, ye who enter here..
Srimalik
Valued Contributor

Re: Erros when using -D_HPUX_API_LEVEL=20040821

Removed uname.
abandon all hope, ye who enter here..