- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Use of function prototypes when linking C code
Operating System - Linux
1753753
Members
5309
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
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
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
09-25-2005 10:13 PM
09-25-2005 10:13 PM
Use of function prototypes when linking C code
Hi, I'd appreciate any insights into this behaviour of the CC compiler.
Hypothetically, I have a function named "myfunc" declared in a library named "mylib.a". In "mysource.c", I'm making use of "myfunc" but I didn't specify a function prototype for it.
When I go about compiling "mysource.c", I would get an "Unsatisfied symbols" error which is all as expected.
A problem arises if I first compile "mysource.c" into "mysource.o" and then linking it with "mylib.a" to generate the executable. There were no errors eventhough the function prototype for "myfunc" is missing.
My questions as follows:
- How does the compiler perform type checking for "myfunc"?
- Is there an option to force the compiler to complain about the missing prototype? (some sort fo an GCC -Wmissing-prototypes equivalent?)
Thanks in advance.
Hypothetically, I have a function named "myfunc" declared in a library named "mylib.a". In "mysource.c", I'm making use of "myfunc" but I didn't specify a function prototype for it.
When I go about compiling "mysource.c", I would get an "Unsatisfied symbols" error which is all as expected.
A problem arises if I first compile "mysource.c" into "mysource.o" and then linking it with "mylib.a" to generate the executable. There were no errors eventhough the function prototype for "myfunc" is missing.
My questions as follows:
- How does the compiler perform type checking for "myfunc"?
- Is there an option to force the compiler to complain about the missing prototype? (some sort fo an GCC -Wmissing-prototypes equivalent?)
Thanks in advance.
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2005 10:20 PM
09-25-2005 10:20 PM
Re: Use of function prototypes when linking C code
a) Linking of libraries are related to Link editor. It is checking for the type checking of functions with program and libraries. It is the one generating error's as "Unsatisfied symbols".
You can test it as,
# cc -v mysource.c -o mysource
# cc -v mysource.c -o mysource
It will give details.
b) Change Linker editor ld settings with,
+k Direct the linker to only create an executable if
there were no errors encountered during the link.
If there were errors found (system errors or
unresolved references), the output file will be
removed.
+n Causes the linker to load all object modules
before searching any archive or shared libraries.
Then it searches the archive and shared libraries
specified on the command line in left to right
order. Repeats the left to right search of the
libraries on the command line until there are no
more unsatisfied symbols, or the last search added
no new definitions. This option is useful if two
libraries are specified that have symbol
dependencies on each other.
hth.
You can test it as,
# cc -v mysource.c -o mysource
# cc -v mysource.c -o mysource
It will give details.
b) Change Linker editor ld settings with,
+k Direct the linker to only create an executable if
there were no errors encountered during the link.
If there were errors found (system errors or
unresolved references), the output file will be
removed.
+n Causes the linker to load all object modules
before searching any archive or shared libraries.
Then it searches the archive and shared libraries
specified on the command line in left to right
order. Repeats the left to right search of the
libraries on the command line until there are no
more unsatisfied symbols, or the last search added
no new definitions. This option is useful if two
libraries are specified that have symbol
dependencies on each other.
hth.
Easy to suggest when don't know about the problem!
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