- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- "almost" empty source file, object file size ?
Operating System - HP-UX
1753747
Members
4950
Online
108799
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО12-29-2003 07:54 PM
тАО12-29-2003 07:54 PM
"almost" empty source file, object file size ?
i was facing a problem with my ansi-C compiler, so i decided to give it a try using aCC,
and the behaviour turned out to be the same.
consider the following piece of code in a file:
#ifdef _AS
#include
#include
#define XMAS christmas()
int x = 2;
void gogetit(int a) {
printf("%d", a);
}
#endif /* _AS */
compile it using "aCC -Aa -g -c 1.c", and it says:
Warning 336: Unknown position # Entire translation unit was empty.
compile it using "cc -Aa -g -c 1.c", and it says:
cc: "1.c", line 1: warning 501: Empty source file.
but, if i move my #ifdef _AS *after* the 2 #include's i.e.
#include
#include
#ifdef _AS
#define XMAS christmas()
the file compiles fine, i.e. no warnings/errors, and a finite size 1.o is created,
of 552 bytes (using aCC) and 580 bytes (using cc i.e. anis-C compiler).
if i run "nm" over it, it says "no symbols".
my questions are:
(1) how is the inclusing of stdio.h giving the compiler "code" to assume the
translation unit to be non-empty ?
(2) what exactly is this code, since the 1.o is non-empty ?
(3) since 1.o is non-empty, why is "nm" saying "no symbol" for a finite sized
1.o and source compiled with -g option ?
and the behaviour turned out to be the same.
consider the following piece of code in a file:
#ifdef _AS
#include
#include
#define XMAS christmas()
int x = 2;
void gogetit(int a) {
printf("%d", a);
}
#endif /* _AS */
compile it using "aCC -Aa -g -c 1.c", and it says:
Warning 336: Unknown position # Entire translation unit was empty.
compile it using "cc -Aa -g -c 1.c", and it says:
cc: "1.c", line 1: warning 501: Empty source file.
but, if i move my #ifdef _AS *after* the 2 #include's i.e.
#include
#include
#ifdef _AS
#define XMAS christmas()
the file compiles fine, i.e. no warnings/errors, and a finite size 1.o is created,
of 552 bytes (using aCC) and 580 bytes (using cc i.e. anis-C compiler).
if i run "nm" over it, it says "no symbols".
my questions are:
(1) how is the inclusing of stdio.h giving the compiler "code" to assume the
translation unit to be non-empty ?
(2) what exactly is this code, since the 1.o is non-empty ?
(3) since 1.o is non-empty, why is "nm" saying "no symbol" for a finite sized
1.o and source compiled with -g option ?
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-29-2003 10:02 PM
тАО12-29-2003 10:02 PM
Re: "almost" empty source file, object file size ?
The source is parsed by the C pre processor before going through the 'real' compiler. This preporcessor will parse the lines starting with the hashes, like #ifdef etc. When compiling, _AS is not defined normally, resulting in everything, including, between the #ifdef and the #endif to be skipped.
This means that nothing has to be compiled, which in turn results in your errors/warnings
When moving the #include's to the top, the contents of those included files will be compiled.
To prevent this, add some line, like a line containing revision info, at the top of your C-sources.
This means that nothing has to be compiled, which in turn results in your errors/warnings
When moving the #include's to the top, the contents of those included files will be compiled.
To prevent this, add some line, like a line containing revision info, at the top of your C-sources.
Every problem has at least one solution. Only some solutions are harder to find.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-29-2003 10:57 PM
тАО12-29-2003 10:57 PM
Re: "almost" empty source file, object file size ?
When compiling stdio.h, an object file will be generated with empty parts ('cat -tv' shows as much, though it might be hard to read). The input not being empty just tells the compiler to generate valid output. And this .o is an 'empty' output.
There are no routines, no variables, just empty blocks.
Though not for the faint of heart, take a look at the manual pages of a.out and elf.
There are no routines, no variables, just empty blocks.
Though not for the faint of heart, take a look at the manual pages of a.out and elf.
Every problem has at least one solution. Only some solutions are harder to find.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP