Article View: gnu.g++.help
Article #467Header file problems
From: Michael Tiemann
Date: Tue, 05 Feb 1991 03:16
Date: Tue, 05 Feb 1991 03:16
63 lines
2113 bytes
2113 bytes
Date: 4 Feb 91 02:52:38 GMT
From: jz0o+@andrew.cmu.edu (Jason Yeoung Zien)
Organization: Class of '91, Carnegie Mellon, Pittsburgh, PA
Sender: help-g++-request@prep.ai.mit.edu
I am having problems incorporating K&R style header files into my C++
programs. g++ doesn't seem to like them at all.
I have this following very simple header file & program, which will not
compile with g++:
func.c
------------------------------------
#include "func.h"
func(i)
int *i;
{
*i = 22;
}
--------------------------------------
func.h
---------------------------------------
/* func(int *); */
func();
test.c
---------------------------------
#include <stdio.h>
#include "func.h"
main()
{
float i=11.11;
int num;
func(&num);
printf("Starting. %d\n",num);
}
When it compiles, it gives the following errors/warnings:
g++ func.o test.c
In file included from test.c:2:
func.h:2: warning: data definition lacks type or storage class
func.h: In function int main ():
func.h:2: too many arguments to function `int func ()'
test.c:9: at this point in file
What can I do to correct this problem? I tried using:
g++ -traditional func.o test.c,
but that gives the error:
test.o: Undefined symbol func(...) referenced from text segment
Any help would be much appreciated.
Read g++.texinfo about why this doesn't work.
Michael
Technical Details
Message-ID:
<9102050316.AA10014@teacake.Eng.Sun.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!sdd.hp.com!spool.mu.edu!uwm.edu!linac!pacific.mps.ohio-state.edu!tut.cis.ohio-state.edu!eng.sun.com!tiemannReferences:
<cbfAlqK00VpDF3C0ck@andrew.cmu.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!sdd.hp.com!spool.mu.edu!uwm.edu!linac!pacific.mps.ohio-state.edu!tut.cis.ohio-state.edu!eng.sun.com!tiemann From: tiemann@eng.sun.com (Michael Tiemann) Newsgroups: gnu.g++.help,comp.lang.c++ Subject: Header file problems Message-ID: <9102050316.AA10014@teacake.Eng.Sun.COM> Date: 5 Feb 91 03:16:38 GMT References: <cbfAlqK00VpDF3C0ck@andrew.cmu.edu> Sender: daemon@tut.cis.ohio-state.edu Reply-To: tiemann@cygnus.com Followup-To: gnu.g++.help Organization: Cygnus Support (+1 415 322 3811) Lines: 63