- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- C compiling in UX
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2005 02:43 PM
02-22-2005 02:43 PM
C compiling in UX
I have this really fundamental question.. how to u compile a C source code in UX?
e.g. source code "test.c"
#inclde
void main(){
printf("hello world");
}
I try compiling "cc test.c"
but it keep givin me
/usr/ccs/bin/ld: Unexpected end of file in test.c
wats wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2005 03:41 PM
02-22-2005 03:41 PM
Re: C compiling in UX
> #inclde
> void main(){
> printf("hello world");
> }
to
#include
int main ()
{
printf ("hello world");
return 0;
}
The real error in you code is the first line (#include).
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2005 03:48 PM
02-22-2005 03:48 PM
Re: C compiling in UX
#include
#include
void main(){
printf("hello world");
}
Compile as,
cc -v test.c
It will give more informations.
HTH.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2005 03:51 PM
02-22-2005 03:51 PM
Re: C compiling in UX
It's bad programming practice to use
void main().
In C, main() is designed to return int, so
int main() is what you should be using.
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2005 05:00 PM
02-22-2005 05:00 PM
Re: C compiling in UX
"
#include
#include
#include
#include
#include
main() {
char fn[]="try.txt";
struct stat info;
int file_descriptor;
if ((file_descriptor = creat(fn, S_IWUSR)) < 0)
perror("creat() error");
else {
if (fstat(file_descriptor, &info) != 0)
perror("fstat() error");
else {
puts("fstat() returned:");
printf(" inode: %d\n", (int) info.st_ino);
printf(" dev id: %d\n", (int) info.st_dev);
printf(" mode: %08x\n", info.st_mode);
printf(" links: %d\n", info.st_nlink);
printf(" uid: %d\n", (int) info.st_uid);
printf(" gid: %d\n", (int) info.st_gid);
}
close(file_descriptor);
unlink(fn);
}
}
"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2005 05:26 PM
02-22-2005 05:26 PM
Re: C compiling in UX
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2005 05:32 PM
02-22-2005 05:32 PM
Re: C compiling in UX
ran fine on my HP-UX 11.11 system. What exactly
is the problem you are seeing?
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2005 05:43 PM
02-22-2005 05:43 PM
Re: C compiling in UX
At the end of C file, give one new line. hope It will solve your problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2005 05:49 PM
02-22-2005 05:49 PM
Re: C compiling in UX
In Editor, at the end of C file, give one new line(ENTER) . hope It will solve your problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2005 06:01 PM
02-22-2005 06:01 PM
Re: C compiling in UX
C compilers don't usually care anout an extra line at
the end of C file.
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2005 07:28 PM
02-22-2005 07:28 PM
Re: C compiling in UX
"cc: "test.c", line 8: error 1716: Automatic aggregate initialization is an ANSI feature."
so I decided to do it this way "cc -Aa test.c"
it then gives me: "
cc: "test.c", line 9: error 1574: Unknown size for "info".
cc: "test.c", line 12: error 1588: "S_IWUSR" undefined.
cc: "test.c", line 19: error 1530: Undefined struct or union.
cc: "test.c", line 19: error 1527: Incompatible types in cast: Must cast from scalar to scalar or to void type.
cc: "test.c", line 20: error 1530: Undefined struct or union.
cc: "test.c", line 20: error 1527: Incompatible types in cast: Must cast from scalar to scalar or to void type.
cc: "test.c", line 21: error 1530: Undefined struct or union.
cc: "test.c", line 21: warning 563: Argument #2 is not the correct type.
cc: "test.c", line 22: error 1530: Undefined struct or union.
cc: "test.c", line 22: warning 563: Argument #2 is not the correct type.
cc: "test.c", line 23: error 1530: Undefined struct or union.
cc: "test.c", line 23: error 1527: Incompatible types in cast: Must cast from scalar to scalar or to void type.
cc: "test.c", line 24: error 1530: Undefined struct or union.
cc: "test.c", line 24: error 1527: Incompatible types in cast: Must cast from scalar to scalar or to void type.
"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2005 07:35 PM
02-22-2005 07:35 PM
Re: C compiling in UX
if you are going to use C more often it may be worthwhile getting the proper C compiler.
Either buy the HP product or use free gcc.
The compiler with the OS is normally only used for kernel compiles, so may not have full functionality.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2005 08:01 PM
02-22-2005 08:01 PM
Re: C compiling in UX
if this the case, can u advise me where I should go to download the gcc for my hpux10.20b . What should I do to install it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2005 08:52 PM
02-22-2005 08:52 PM
Re: C compiling in UX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2005 05:21 AM
02-23-2005 05:21 AM
Re: C compiling in UX
I tried to compile your code on a 11.11 system that
does not have a ANSI C compiler and I did get the
error you are getting ("Automatic aggregate
initialization is an ANSI feature"). The native C
compiler seems to have a problem with the line
char fn[]="try.txt";
Changing the above line to the following fixed the
problem and the program compiled fine without
ANSI compiler and ran fine.
char *fn = "try.txt;
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2005 01:08 PM
02-23-2005 01:08 PM
Re: C compiling in UX
Thanks for the feedback, I am trying to install the GNU C compiler now.. but as for the latter, do you see the other errors I have after fixing the first problem? thank u
Best regards
Henry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2005 02:47 PM
02-23-2005 02:47 PM
Re: C compiling in UX
> do you see the other errors I have after fixing the
> first problem? thank u
Though I did not see the other errors, I think all of
them have one source, the compiler does not know
about the struct stat. As this is defined in
sys/stat.h, my guess is that the header is not
included correctly in your code. Make sure that the
line
#include
in your code starts from the first column of the line
(i.e no spaces before # character).
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2005 06:59 PM
02-23-2005 06:59 PM
Re: C compiling in UX
looking at your new thread postings, I guess you managed to get a copy of the 10.20 gcc code and have installed it.
Can you please assign points to answers and close the thread.
Happy coding!
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2005 08:43 PM
02-23-2005 08:43 PM