1753829 Members
8852 Online
108806 Solutions
New Discussion юеВ

cc compiler problem

 
SOLVED
Go to solution
yangk
Frequent Advisor

cc compiler problem

Deal All,

I have a simple c code like this:

#define _HPUX_API_LEVEL 20040821
#if !defined(__GNUC__) || (__GNUC__ < 2)
# define __attribute__(x)
#endif

#include
#include
#include
#include

int main()
{
struct utsname osname;
if(uname(&osname)<0)
{
printf("%d %s\n",errno,strerror(errno));
printf("error\n");
}
printf("%s\n",osname.release);

return 0;
}

to use the expand hostname.
But if define the following line,it will
create errors:
72 Value too large to be stored in data type
error

#if !defined(__GNUC__) || (__GNUC__ < 2)
# define __attribute__(x)
#endif


The reason is that in the /usr/include/sys/stdsyms.h there is line:

#define _HPUX_API_VERS_20040821_ATTR __attribute__((version_id("20040821")))

That may be cause the error.

So can anyone give me some help?
Thanks!

Kevin,


4 REPLIES 4
Dennis Handly
Acclaimed Contributor
Solution

Re: cc compiler problem

What OS version are you using? What C compiler version are you using?

#if !defined(__GNUC__) || (__GNUC__ < 2)
# define __attribute__(x)

You can't do this if you want to use longer hostnames.

>if define the following line, it will create errors:

Yes. It appears you already know the cause and answer, remove those bogus #if lines.
yangk
Frequent Advisor

Re: cc compiler problem

Hi dennis,

My OS is :
uname -a
HP-UX test567890 B.11.31 U 9000/800 2404418694 unlimited-user license

And the cc version is :
what /opt/ansic/bin/cc
/opt/ansic/bin/cc:
$Revision: 92453-07 linker linker crt0.o B.11.53 060807 $
LINT B.11.11.18 CXREF B.11.11.18
HP92453-01 B.11.11.18 HP C Compiler
$ PATCH/11.00:PHCO_27774 Oct 3 2002 09:45:59 $
Dennis Handly
Acclaimed Contributor

Re: cc compiler problem

Do you still have any questions?
yangk
Frequent Advisor

Re: cc compiler problem

Hi dennis,

Thank you very much, now i have no questions about this!