tiemann@eng.sun.com (Michael Tiemann) (02/05/91)
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